> ## Documentation Index
> Fetch the complete documentation index at: https://cdktn.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Python: TerraformVariable

> CDKTN Core API Reference for TerraformVariable in Python.

* *Implements:* <a href="#cdktn.ITerraformAddressable">ITerraformAddressable</a>

## Initializers <a name="Initializers" id="cdktn.TerraformVariable.Initializer" />

```python theme={null}
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
)
```

| **Name**                                                                                          | **Type**                                                                                                            | **Description**                                                                                                                              |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.scope">scope</a></code>             | <code>constructs.Construct</code>                                                                                   | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.id">id</a></code>                   | <code>str</code>                                                                                                    | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.default">default</a></code>         | <code>typing.Any</code>                                                                                             | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.description">description</a></code> | <code>str</code>                                                                                                    | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.nullable">nullable</a></code>       | <code>bool</code>                                                                                                   | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.sensitive">sensitive</a></code>     | <code>bool</code>                                                                                                   | *No description.*                                                                                                                            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.type">type</a></code>               | <code>str</code>                                                                                                    | 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.            |
| <code><a href="#cdktn.TerraformVariable.Initializer.parameter.validation">validation</a></code>   | <code>typing.List\[<a href="#cdktn.TerraformVariableValidationConfig">TerraformVariableValidationConfig</a>]</code> | Specify arbitrary custom validation rules for a particular variable using a validation block nested within the corresponding variable block. |

***

### `scope`<sup>Required</sup> <a name="scope" id="cdktn.TerraformVariable.Initializer.parameter.scope" />

* *Type:* constructs.Construct

***

### `id`<sup>Required</sup> <a name="id" id="cdktn.TerraformVariable.Initializer.parameter.id" />

* *Type:* str

***

### `default`<sup>Optional</sup> <a name="default" id="cdktn.TerraformVariable.Initializer.parameter.default" />

* *Type:* typing.Any

***

### `description`<sup>Optional</sup> <a name="description" id="cdktn.TerraformVariable.Initializer.parameter.description" />

* *Type:* str

***

### `nullable`<sup>Optional</sup> <a name="nullable" id="cdktn.TerraformVariable.Initializer.parameter.nullable" />

* *Type:* bool

***

### `sensitive`<sup>Optional</sup> <a name="sensitive" id="cdktn.TerraformVariable.Initializer.parameter.sensitive" />

* *Type:* bool

***

### `type`<sup>Optional</sup> <a name="type" id="cdktn.TerraformVariable.Initializer.parameter.type" />

* *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](https://developer.hashicorp.com/terraform/language/expressions/type-constraints).

If both the type and default arguments are specified, the given default value must be convertible to the specified type.

***

### `validation`<sup>Optional</sup> <a name="validation" id="cdktn.TerraformVariable.Initializer.parameter.validation" />

* *Type:* typing.List\[<a href="#cdktn.TerraformVariableValidationConfig">TerraformVariableValidationConfig</a>]

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

***

## Methods <a name="Methods" id="Methods" />

| **Name**                                                                                                | **Description**                                                                   |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| <code><a href="#cdktn.TerraformVariable.toString">to\_string</a></code>                                 | Returns a string representation of this construct.                                |
| <code><a href="#cdktn.TerraformVariable.with">with</a></code>                                           | Applies one or more mixins to this construct.                                     |
| <code><a href="#cdktn.TerraformVariable.addOverride">add\_override</a></code>                           | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.overrideLogicalId">override\_logical\_id</a></code>             | Overrides the auto-generated logical ID with a specific ID.                       |
| <code><a href="#cdktn.TerraformVariable.resetOverrideLogicalId">reset\_override\_logical\_id</a></code> | Resets a previously passed logical Id to use the auto-generated logical id again. |
| <code><a href="#cdktn.TerraformVariable.toHclTerraform">to\_hcl\_terraform</a></code>                   | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.toMetadata">to\_metadata</a></code>                             | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.toTerraform">to\_terraform</a></code>                           | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.addValidation">add\_validation</a></code>                       | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.synthesizeAttributes">synthesize\_attributes</a></code>         | *No description.*                                                                 |
| <code><a href="#cdktn.TerraformVariable.synthesizeHclAttributes">synthesize\_hcl\_attributes</a></code> | *No description.*                                                                 |

***

### `to_string` <a name="to_string" id="cdktn.TerraformVariable.toString" />

```python theme={null}
def to_string() -> str
```

Returns a string representation of this construct.

### `with` <a name="with" id="cdktn.TerraformVariable.with" />

```python theme={null}
def with(
  mixins: *IMixin
) -> IConstruct
```

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple `with()` calls if subsequent mixins should apply to added
constructs.

#### `mixins`<sup>Required</sup> <a name="mixins" id="cdktn.TerraformVariable.with.parameter.mixins" />

* *Type:* \*constructs.IMixin

The mixins to apply.

***

### `add_override` <a name="add_override" id="cdktn.TerraformVariable.addOverride" />

```python theme={null}
def add_override(
  path: str,
  value: typing.Any
) -> None
```

#### `path`<sup>Required</sup> <a name="path" id="cdktn.TerraformVariable.addOverride.parameter.path" />

* *Type:* str

***

#### `value`<sup>Required</sup> <a name="value" id="cdktn.TerraformVariable.addOverride.parameter.value" />

* *Type:* typing.Any

***

### `override_logical_id` <a name="override_logical_id" id="cdktn.TerraformVariable.overrideLogicalId" />

```python theme={null}
def override_logical_id(
  new_logical_id: str
) -> None
```

Overrides the auto-generated logical ID with a specific ID.

#### `new_logical_id`<sup>Required</sup> <a name="new_logical_id" id="cdktn.TerraformVariable.overrideLogicalId.parameter.newLogicalId" />

* *Type:* str

The new logical ID to use for this stack element.

***

### `reset_override_logical_id` <a name="reset_override_logical_id" id="cdktn.TerraformVariable.resetOverrideLogicalId" />

```python theme={null}
def reset_override_logical_id() -> None
```

Resets a previously passed logical Id to use the auto-generated logical id again.

### `to_hcl_terraform` <a name="to_hcl_terraform" id="cdktn.TerraformVariable.toHclTerraform" />

```python theme={null}
def to_hcl_terraform() -> typing.Any
```

### `to_metadata` <a name="to_metadata" id="cdktn.TerraformVariable.toMetadata" />

```python theme={null}
def to_metadata() -> typing.Any
```

### `to_terraform` <a name="to_terraform" id="cdktn.TerraformVariable.toTerraform" />

```python theme={null}
def to_terraform() -> typing.Any
```

### `add_validation` <a name="add_validation" id="cdktn.TerraformVariable.addValidation" />

```python theme={null}
def add_validation(
  condition: typing.Any,
  error_message: str
) -> None
```

#### `condition`<sup>Required</sup> <a name="condition" id="cdktn.TerraformVariable.addValidation.parameter.condition" />

* *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_message`<sup>Required</sup> <a name="error_message" id="cdktn.TerraformVariable.addValidation.parameter.errorMessage" />

* *Type:* str

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

***

### `synthesize_attributes` <a name="synthesize_attributes" id="cdktn.TerraformVariable.synthesizeAttributes" />

```python theme={null}
def synthesize_attributes() -> typing.Mapping[typing.Any]
```

### `synthesize_hcl_attributes` <a name="synthesize_hcl_attributes" id="cdktn.TerraformVariable.synthesizeHclAttributes" />

```python theme={null}
def synthesize_hcl_attributes() -> typing.Mapping[typing.Any]
```

## Static Functions <a name="Static Functions" id="Static Functions" />

| **Name**                                                                                      | **Description**               |
| --------------------------------------------------------------------------------------------- | ----------------------------- |
| <code><a href="#cdktn.TerraformVariable.isConstruct">is\_construct</a></code>                 | Checks if `x` is a construct. |
| <code><a href="#cdktn.TerraformVariable.isTerraformElement">is\_terraform\_element</a></code> | *No description.*             |

***

### `is_construct` <a name="is_construct" id="cdktn.TerraformVariable.isConstruct" />

```python theme={null}
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.

#### `x`<sup>Required</sup> <a name="x" id="cdktn.TerraformVariable.isConstruct.parameter.x" />

* *Type:* typing.Any

Any object.

***

### `is_terraform_element` <a name="is_terraform_element" id="cdktn.TerraformVariable.isTerraformElement" />

```python theme={null}
import cdktn

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

#### `x`<sup>Required</sup> <a name="x" id="cdktn.TerraformVariable.isTerraformElement.parameter.x" />

* *Type:* typing.Any

***

## Properties <a name="Properties" id="Properties" />

| **Name**                                                                                           | **Type**                                                                                                            | **Description**   |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------- |
| <code><a href="#cdktn.TerraformVariable.property.node">node</a></code>                             | <code>constructs.Node</code>                                                                                        | The tree node.    |
| <code><a href="#cdktn.TerraformVariable.property.cdktfStack">cdktf\_stack</a></code>               | <code><a href="#cdktn.TerraformStack">TerraformStack</a></code>                                                     | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.fqn">fqn</a></code>                               | <code>str</code>                                                                                                    | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.friendlyUniqueId">friendly\_unique\_id</a></code> | <code>str</code>                                                                                                    | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.booleanValue">boolean\_value</a></code>           | <code><a href="#cdktn.IResolvable">IResolvable</a></code>                                                           | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.listValue">list\_value</a></code>                 | <code>typing.List\[str]</code>                                                                                      | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.numberValue">number\_value</a></code>             | <code>typing.Union\[int, float]</code>                                                                              | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.stringValue">string\_value</a></code>             | <code>str</code>                                                                                                    | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.value">value</a></code>                           | <code>typing.Any</code>                                                                                             | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.default">default</a></code>                       | <code>typing.Any</code>                                                                                             | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.description">description</a></code>               | <code>str</code>                                                                                                    | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.nullable">nullable</a></code>                     | <code>bool</code>                                                                                                   | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.sensitive">sensitive</a></code>                   | <code>bool</code>                                                                                                   | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.type">type</a></code>                             | <code>str</code>                                                                                                    | *No description.* |
| <code><a href="#cdktn.TerraformVariable.property.validation">validation</a></code>                 | <code>typing.List\[<a href="#cdktn.TerraformVariableValidationConfig">TerraformVariableValidationConfig</a>]</code> | *No description.* |

***

### `node`<sup>Required</sup> <a name="node" id="cdktn.TerraformVariable.property.node" />

```python theme={null}
node: Node
```

* *Type:* constructs.Node

The tree node.

***

### `cdktf_stack`<sup>Required</sup> <a name="cdktf_stack" id="cdktn.TerraformVariable.property.cdktfStack" />

```python theme={null}
cdktf_stack: TerraformStack
```

* *Type:* <a href="#cdktn.TerraformStack">TerraformStack</a>

***

### `fqn`<sup>Required</sup> <a name="fqn" id="cdktn.TerraformVariable.property.fqn" />

```python theme={null}
fqn: str
```

* *Type:* str

***

### `friendly_unique_id`<sup>Required</sup> <a name="friendly_unique_id" id="cdktn.TerraformVariable.property.friendlyUniqueId" />

```python theme={null}
friendly_unique_id: str
```

* *Type:* str

***

### `boolean_value`<sup>Required</sup> <a name="boolean_value" id="cdktn.TerraformVariable.property.booleanValue" />

```python theme={null}
boolean_value: IResolvable
```

* *Type:* <a href="#cdktn.IResolvable">IResolvable</a>

***

### `list_value`<sup>Required</sup> <a name="list_value" id="cdktn.TerraformVariable.property.listValue" />

```python theme={null}
list_value: typing.List[str]
```

* *Type:* typing.List\[str]

***

### `number_value`<sup>Required</sup> <a name="number_value" id="cdktn.TerraformVariable.property.numberValue" />

```python theme={null}
number_value: typing.Union[int, float]
```

* *Type:* typing.Union\[int, float]

***

### `string_value`<sup>Required</sup> <a name="string_value" id="cdktn.TerraformVariable.property.stringValue" />

```python theme={null}
string_value: str
```

* *Type:* str

***

### `value`<sup>Required</sup> <a name="value" id="cdktn.TerraformVariable.property.value" />

```python theme={null}
value: typing.Any
```

* *Type:* typing.Any

***

### `default`<sup>Optional</sup> <a name="default" id="cdktn.TerraformVariable.property.default" />

```python theme={null}
default: typing.Any
```

* *Type:* typing.Any

***

### `description`<sup>Optional</sup> <a name="description" id="cdktn.TerraformVariable.property.description" />

```python theme={null}
description: str
```

* *Type:* str

***

### `nullable`<sup>Optional</sup> <a name="nullable" id="cdktn.TerraformVariable.property.nullable" />

```python theme={null}
nullable: bool
```

* *Type:* bool

***

### `sensitive`<sup>Optional</sup> <a name="sensitive" id="cdktn.TerraformVariable.property.sensitive" />

```python theme={null}
sensitive: bool
```

* *Type:* bool

***

### `type`<sup>Optional</sup> <a name="type" id="cdktn.TerraformVariable.property.type" />

```python theme={null}
type: str
```

* *Type:* str

***

### `validation`<sup>Optional</sup> <a name="validation" id="cdktn.TerraformVariable.property.validation" />

```python theme={null}
validation: typing.List[TerraformVariableValidationConfig]
```

* *Type:* typing.List\[<a href="#cdktn.TerraformVariableValidationConfig">TerraformVariableValidationConfig</a>]

***
