Number
Number is a primitive data type used to save numeric data.
Common usage
Use number properties to store measurements and counts ingested from your tools, such as:
- Open vulnerability counts.
- CPU and memory allocations.
- Deployment replica counts.
- Monthly cloud costs.
API definition
- Basic
- Enum
- Array
- Enum Array
{
"myNumberProp": {
"title": "My number",
"icon": "My icon",
"description": "My number property",
"type": "number",
"default": 7
}
}
{
"myNumberEnum": {
"title": "My number enum",
"icon": "My icon",
"description": "My number enum",
"type": "number",
"enum": [1, 2, 3, 4]
}
}
{
"myNumberArray": {
"title": "My number array",
"icon": "My icon",
"description": "My number array",
"type": "array",
"items": {
"type": "number"
}
}
}
{
"myNumberArray": {
"title": "My number enum array",
"icon": "My icon",
"description": "My number enum array",
"type": "array",
"items": {
"type": "number",
"enum": [1, 2, 3, 4],
"enumColors": {
"1": "red",
"2": "green",
"3": "blue"
}
}
}
}
Check out Port's API reference to learn more.
Terraform definition
The examples below use version 2.29.0 of the Terraform and Pulumi providers. Configure your provider first, then run one example at a time in its own project. Each example creates a blueprint; use distinct identifiers when you combine examples.
- Basic
- Enum
- Array
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
number_props = {
"myNumberProp" = {
title = "My number"
description = "My number property"
default = 7
}
}
}
}
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
number_props = {
"myNumberProp" = {
title = "My number"
description = "My number property"
enum = [1, 2, 3, 4]
}
}
}
}
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
array_props = {
"myNumberArray" = {
title = "My number array"
description = "My number array"
number_items = {}
}
"myNumberArrayWithDefault" = {
title = "My number array with default"
description = "My number array"
number_items = {
default = [1, 2, 3, 4]
}
}
}
}
}
Pulumi definition
- Basic
- Python
- TypeScript
- JavaScript
- Go
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesNumberPropsArgs
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
number_props={
"myNumberProp": BlueprintPropertiesNumberPropsArgs(
title="My number", required=False,
)
},
),
relations={}
)
import * as pulumi from "@pulumi/pulumi";
import * as port from "@port-labs/port";
export const blueprint = new port.Blueprint("myBlueprint", {
identifier: "myBlueprint",
title: "My Blueprint",
properties: {
numberProps: {
myNumberProp: {
title: "My number",
required: false,
},
},
},
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
title: "My Blueprint",
identifier: "myBlueprint",
properties: {
numberProps: {
myNumberProp: {
title: "My number",
required: false,
},
},
},
relations: {},
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/v2/go/port"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
blueprint, err := port.NewBlueprint(ctx, "myBlueprint", &port.BlueprintArgs{
Identifier: pulumi.String("myBlueprint"),
Title: pulumi.String("My Blueprint"),
Properties: port.BlueprintPropertiesArgs{
NumberProps: port.BlueprintPropertiesNumberPropsMap{
"myNumberProp": port.BlueprintPropertiesNumberPropsArgs{
Title: pulumi.String("My number"),
Required: pulumi.Bool(false),
},
},
},
})
if err != nil {
return err
}
ctx.Export("blueprint", blueprint.Title)
return nil
})
}
Validate number
Number validations support the following operators:
range
Ranges of numbers are specified using a combination of the minimum and maximum keywords, (or exclusiveMinimum and exclusiveMaximum for expressing exclusive range).
If x is the value being validated, the following must hold true:
- x ≥
minimum - x >
exclusiveMinimum - x ≤
maximum - x <
exclusiveMaximum
- Basic
- Array
- Terraform
{
"myNumberProp": {
"title": "My number",
"icon": "My icon",
"description": "My number property",
"type": "number",
"minimum": 0,
"maximum": 50
}
}
{
"myNumberArray": {
"title": "My number array",
"icon": "My icon",
"description": "My number array",
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0,
"exclusiveMaximum": 50
}
}
}
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
"number_props" = {
"myNumberProp" = {
title = "My number"
icon = "My icon"
description = "My number property"
minimum = 0
maximum = 50
}
}
}
}