Skip to main content

Initializers

import cdktn

cdktn.MapTerraformIterator(
  map: AnyMap | StringMap | NumberMap | BooleanMap | ComplexMap | typing.Mapping[typing.Any] | typing.Mapping[str] | typing.Mapping[typing.Union[int, float]]
)
NameTypeDescription
mapAnyMap | StringMap | NumberMap | BooleanMap | ComplexMap | typing.Mapping[typing.Any] | typing.Mapping[str] | typing.Mapping[typing.Union[int, float]]No description.

mapRequired


Methods

NameDescription
dynamicCreates a dynamic expression that can be used to loop over this iterator in a dynamic block.
for_expression_for_listCreates a for expression that results in a list.
for_expression_for_mapCreates a for expression that results in a map.
get_anyNo description.
get_any_mapNo description.
get_booleanNo description.
get_boolean_mapNo description.
get_listNo description.
get_mapNo description.
get_numberNo description.
get_number_listNo description.
get_number_mapNo description.
get_stringNo description.
get_string_mapNo description.
keysCreates a for expression that maps the iterators to its keys.
pluck_propertyCreates a for expression that accesses the key on each element of the iterator.
valuesCreates a for expression that maps the iterators to its value in case it is a map.

dynamic

def dynamic(
  attributes: typing.Mapping[typing.Any]
) -> IResolvable
Creates a dynamic expression that can be used to loop over this iterator in a dynamic block. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString. See https://developer.hashicorp.com/terraform/cdktf/concepts/iterators#using-iterators-for-list-attributes

attributesRequired

  • Type: typing.Mapping[typing.Any]

for_expression_for_list

def for_expression_for_list(
  expression: str | IResolvable
) -> IResolvable
Creates a for expression that results in a list. This method allows you to create every possible for expression, but requires more knowledge about Terraform’s for expression syntax. For the most common use cases you can use keys(), values(), and pluckProperty() instead. You may write any valid Terraform for each expression, e.g. TerraformIterator.fromList(myIteratorSourceVar).forExpressionForList("val.foo if val.bar == true") will result in [ for key, val in var.myIteratorSource: val.foo if val.bar == true ]. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString.

expressionRequired

The expression to use in the for mapping.

for_expression_for_map

def for_expression_for_map(
  key_expression: str | IResolvable,
  value_expression: str | IResolvable
) -> IResolvable
Creates a for expression that results in a map. This method allows you to create every possible for expression, but requires more knowledge about Terraforms for expression syntax. For the most common use cases you can use keys(), values(), and pluckProperty instead. You may write any valid Terraform for each expression, e.g. TerraformIterator.fromMap(myIteratorSourceVar).forExpressionForMap("key", "val.foo if val.bar == true") will result in \{ for key, val in var.myIteratorSource: key => val.foo if val.bar == true }. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString.

key_expressionRequired

The expression to use as key in the for mapping.

value_expressionRequired

The expression to use as value in the for mapping.

get_any

def get_any(
  attribute: str
) -> IResolvable

attributeRequired

  • Type: str
name of the property to retrieve.

get_any_map

def get_any_map(
  attribute: str
) -> typing.Mapping[typing.Any]

attributeRequired

  • Type: str
name of the property to retrieve.

get_boolean

def get_boolean(
  attribute: str
) -> IResolvable

attributeRequired

  • Type: str
name of the property to retrieve.

get_boolean_map

def get_boolean_map(
  attribute: str
) -> typing.Mapping[bool]

attributeRequired

  • Type: str
name of the property to retrieve.

get_list

def get_list(
  attribute: str
) -> typing.List[str]

attributeRequired

  • Type: str
name of the property to retrieve.

get_map

def get_map(
  attribute: str
) -> typing.Mapping[typing.Any]

attributeRequired

  • Type: str
name of the property to retrieve.

get_number

def get_number(
  attribute: str
) -> typing.Union[int, float]

attributeRequired

  • Type: str
name of the property to retrieve.

get_number_list

def get_number_list(
  attribute: str
) -> typing.List[typing.Union[int, float]]

attributeRequired

  • Type: str
name of the property to retrieve.

get_number_map

def get_number_map(
  attribute: str
) -> typing.Mapping[typing.Union[int, float]]

attributeRequired

  • Type: str
name of the property to retrieve.

get_string

def get_string(
  attribute: str
) -> str

attributeRequired

  • Type: str
name of the property to retrieve.

get_string_map

def get_string_map(
  attribute: str
) -> typing.Mapping[str]

attributeRequired

  • Type: str
name of the property to retrieve.

keys

def keys() -> IResolvable
Creates a for expression that maps the iterators to its keys. For lists these would be the indices, for maps the keys. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString.

pluck_property

def pluck_property(
  property: str
) -> IResolvable
Creates a for expression that accesses the key on each element of the iterator. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString.

propertyRequired

  • Type: str
The property of the iterators values to map to.

values

def values() -> IResolvable
Creates a for expression that maps the iterators to its value in case it is a map. For lists these would stay the same. As this returns an IResolvable you might need to wrap the output in a Token, e.g. Token.asString.

Static Functions

NameDescription
from_complex_listCreates a new iterator from a complex list.
from_data_sourcesCreates a new iterator from a data source that has been created with the for_each argument.
from_listCreates a new iterator from a list.
from_mapCreates a new iterator from a map.
from_resourcesCreates a new iterator from a resource that has been created with the for_each argument.

from_complex_list

import cdktn

cdktn.MapTerraformIterator.from_complex_list(
  list: IResolvable | ComplexList | StringMapList | NumberMapList | BooleanMapList | AnyMapList,
  map_key_attribute_name: str
)
Creates a new iterator from a complex list. One example for this would be a list of maps. The list will be converted into a map with the mapKeyAttributeName as the key. Example
# Example automatically generated from non-compiling source. May contain errors.
cert = AcmCertificate(self, "cert",
    domain_name="example.com",
    validation_method="DNS"
)

dvo_iterator = TerraformIterator.from_complex_list(cert.domain_validation_options, "domain_name")

Route53Record(self, "record",
    allow_overwrite=True,
    name=dvo_iterator.get_string("name"),
    records=[dvo_iterator.get_string("record")],
    ttl=60,
    type=dvo_iterator.get_string("type"),
    zone_id=Token.as_string(data_aws_route53_zone_example.zone_id),
    for_each=dvo_iterator
)

listRequired

the list to iterate over.

map_key_attribute_nameRequired

  • Type: str
the name of the attribute that should be used as the key in the map. Visit https://developer.hashicorp.com/terraform/cdktf/concepts/iterators#using-iterators-on-complex-lists for more information.

from_data_sources

import cdktn

cdktn.MapTerraformIterator.from_data_sources(
  resource: ITerraformResource
)
Creates a new iterator from a data source that has been created with the for_each argument.

resourceRequired


from_list

import cdktn

cdktn.MapTerraformIterator.from_list(
  list: typing.List[str] | IResolvable | typing.List[typing.Union[int, float]] | typing.List[bool | IResolvable]
)
Creates a new iterator from a list.

listRequired

  • Type: typing.List[str] | IResolvable | typing.List[typing.Union[int, float]] | typing.List[bool | IResolvable]

from_map

import cdktn

cdktn.MapTerraformIterator.from_map(
  map: ComplexMap | typing.Mapping[typing.Any] | typing.Mapping[str] | typing.Mapping[typing.Union[int, float]] | typing.Mapping[bool]
)
Creates a new iterator from a map.

mapRequired

  • Type: ComplexMap | typing.Mapping[typing.Any] | typing.Mapping[str] | typing.Mapping[typing.Union[int, float]] | typing.Mapping[bool]

from_resources

import cdktn

cdktn.MapTerraformIterator.from_resources(
  resource: ITerraformResource
)
Creates a new iterator from a resource that has been created with the for_each argument.

resourceRequired


Properties

NameTypeDescription
keystrReturns the key of the current entry in the map that is being iterated over.
valuetyping.AnyReturns the value of the current item iterated over.

keyRequired

key: str
  • Type: str
Returns the key of the current entry in the map that is being iterated over.

valueRequired

value: typing.Any
  • Type: typing.Any
Returns the value of the current item iterated over.