Skip to main content

Initializers

import cdktn

cdktn.TerraformVariable(
  scope: Construct,
  id: str,
  default: typing.Any = None,
  description: str = None,
  nullable: bool = None,
  sensitive: bool = None,
  type: str = None,
  validation: typing.List[TerraformVariableValidationConfig] = None
)
NameTypeDescription
scopeconstructs.ConstructNo description.
idstrNo description.
defaulttyping.AnyNo description.
descriptionstrNo description.
nullableboolNo description.
sensitiveboolNo description.
typestrThe type argument in a variable block allows you to restrict the type of value that will be accepted as the value for a variable.
validationtyping.List[TerraformVariableValidationConfig]Specify arbitrary custom validation rules for a particular variable using a validation block nested within the corresponding variable block.

scopeRequired

  • Type: constructs.Construct

idRequired

  • Type: str

defaultOptional

  • Type: typing.Any

descriptionOptional

  • Type: str

nullableOptional

  • Type: bool

sensitiveOptional

  • Type: bool

typeOptional

  • Type: str
The type argument in a variable block allows you to restrict the type of value that will be accepted as the value for a variable. If no type constraint is set then a value of any type is accepted. While type constraints are optional, we recommend specifying them; they serve as easy reminders for users of the module, and allow Terraform to return a helpful error message if the wrong type is used. Type constraints are created from a mixture of type keywords and type constructors. The supported type keywords are:
  • string
  • number
  • bool
The type constructors allow you to specify complex types such as collections:
  • list(< TYPE >)
  • set(< TYPE >)
  • map(< TYPE >)
  • object({< ATTR NAME > = < TYPE >, … })
  • tuple([< TYPE >, …])
The keyword any may be used to indicate that any type is acceptable. For more information on the meaning and behavior of these different types, as well as detailed information about automatic conversion of complex types, refer to Type Constraints. If both the type and default arguments are specified, the given default value must be convertible to the specified type.

validationOptional

Specify arbitrary custom validation rules for a particular variable using a validation block nested within the corresponding variable block.

Methods

NameDescription
to_stringReturns a string representation of this construct.
add_overrideNo description.
override_logical_idOverrides the auto-generated logical ID with a specific ID.
reset_override_logical_idResets a previously passed logical Id to use the auto-generated logical id again.
to_hcl_terraformNo description.
to_metadataNo description.
to_terraformNo description.
add_validationNo description.
synthesize_attributesNo description.
synthesize_hcl_attributesNo description.

to_string

def to_string() -> str
Returns a string representation of this construct.

add_override

def add_override(
  path: str,
  value: typing.Any
) -> None

pathRequired

  • Type: str

valueRequired

  • Type: typing.Any

override_logical_id

def override_logical_id(
  new_logical_id: str
) -> None
Overrides the auto-generated logical ID with a specific ID.

new_logical_idRequired

  • Type: str
The new logical ID to use for this stack element.

reset_override_logical_id

def reset_override_logical_id() -> None
Resets a previously passed logical Id to use the auto-generated logical id again.

to_hcl_terraform

def to_hcl_terraform() -> typing.Any

to_metadata

def to_metadata() -> typing.Any

to_terraform

def to_terraform() -> typing.Any

add_validation

def add_validation(
  condition: typing.Any,
  error_message: str
) -> None

conditionRequired

  • Type: typing.Any
This is a boolean expression that should return true if the intended assumption or guarantee is fulfilled or false if it does not.

error_messageRequired

  • Type: str
This contains the text that Terraform will include as part of error messages when it detects an unmet condition.

synthesize_attributes

def synthesize_attributes() -> typing.Mapping[typing.Any]

synthesize_hcl_attributes

def synthesize_hcl_attributes() -> typing.Mapping[typing.Any]

Static Functions

NameDescription
is_constructChecks if x is a construct.
is_terraform_elementNo description.

is_construct

import cdktn

cdktn.TerraformVariable.is_construct(
  x: typing.Any
)
Checks if x is a construct. Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked. Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired

  • Type: typing.Any
Any object.

is_terraform_element

import cdktn

cdktn.TerraformVariable.is_terraform_element(
  x: typing.Any
)

xRequired

  • Type: typing.Any

Properties

NameTypeDescription
nodeconstructs.NodeThe tree node.
cdktf_stackTerraformStackNo description.
fqnstrNo description.
friendly_unique_idstrNo description.
boolean_valueIResolvableNo description.
list_valuetyping.List[str]No description.
number_valuetyping.Union[int, float]No description.
string_valuestrNo description.
valuetyping.AnyNo description.
defaulttyping.AnyNo description.
descriptionstrNo description.
nullableboolNo description.
sensitiveboolNo description.
typestrNo description.
validationtyping.List[TerraformVariableValidationConfig]No description.

nodeRequired

node: Node
  • Type: constructs.Node
The tree node.

cdktf_stackRequired

cdktf_stack: TerraformStack

fqnRequired

fqn: str
  • Type: str

friendly_unique_idRequired

friendly_unique_id: str
  • Type: str

boolean_valueRequired

boolean_value: IResolvable

list_valueRequired

list_value: typing.List[str]
  • Type: typing.List[str]

number_valueRequired

number_value: typing.Union[int, float]
  • Type: typing.Union[int, float]

string_valueRequired

string_value: str
  • Type: str

valueRequired

value: typing.Any
  • Type: typing.Any

defaultOptional

default: typing.Any
  • Type: typing.Any

descriptionOptional

description: str
  • Type: str

nullableOptional

nullable: bool
  • Type: bool

sensitiveOptional

sensitive: bool
  • Type: bool

typeOptional

type: str
  • Type: str

validationOptional

validation: typing.List[TerraformVariableValidationConfig]