Skip to content

Number

The random_number resource allows the creation of random numbers.

resource "random_number" "name" {
...
}
AttributeDescription

Minimum minimum required


type: int

The minimum number to generate.

minimum = 1000

Maximum maximum required


type: int

The maximum number to generate.

maximum = 2000

These attributes are computed when the config is parsed and applied, and are
therefore only known at parsetime or runtime.

AttributeDescription

Meta ID meta.id

string

The full ID of the resource e.g. resource.type.name.
This is computed from the full resource path:

// given the following resource
resource “container” “ubuntu” {
}

// the resulting id will be resource.container.ubuntu | |

Meta Type meta.type

string

|

The type of the resource.
This taken from the type label of the resource definition.

// given the following resource
resource “container” “ubuntu” {
…
}

// the resulting type will be container

| |

Meta Name meta.name

string

|

The name of the resource.
This taken from the name label of the resource definition.

// given the following resource
resource “container” “ubuntu” {
…
}

// the resulting name will be ubuntu

| |

Value value

type: int

| The generated random number. |

resource "random_number" "port" {
minimum = 10000
maximum = 20000
}
output "random_number" {
value = resource.random_number.port.value
}