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.
Initializers
import { ResourceTerraformIterator } from 'cdktn'
new ResourceTerraformIterator(element: ITerraformResource)
| Name | Type | Description |
|---|
element | ITerraformResource | No description. |
elementRequired
Methods
| Name | Description |
|---|
dynamic | Creates a dynamic expression that can be used to loop over this iterator in a dynamic block. |
forExpressionForList | Creates a for expression that results in a list. |
forExpressionForMap | Creates a for expression that results in a map. |
getAny | No description. |
getAnyMap | No description. |
getBoolean | No description. |
getBooleanMap | No description. |
getList | No description. |
getMap | No description. |
getNumber | No description. |
getNumberList | No description. |
getNumberMap | No description. |
getString | No description. |
getStringMap | No description. |
keys | Creates a for expression that maps the iterators to its keys. |
pluckProperty | Creates a for expression that accesses the key on each element of the iterator. |
values | Creates a for expression that maps the iterators to its value in case it is a map. |
dynamic
public dynamic(attributes: {[ key: string ]: 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: {[ key: string ]: any}
forExpressionForList
public forExpressionForList(expression: string | 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.
public forExpressionForMap(keyExpression: string | IResolvable, valueExpression: string | 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.
keyExpressionRequired
The expression to use as key in the for mapping.
valueExpressionRequired
The expression to use as value in the for mapping.
getAny
public getAny(attribute: string): IResolvable
attributeRequired
name of the property to retrieve.
getAnyMap
public getAnyMap(attribute: string): {[ key: string ]: any}
attributeRequired
name of the property to retrieve.
getBoolean
public getBoolean(attribute: string): IResolvable
attributeRequired
name of the property to retrieve.
getBooleanMap
public getBooleanMap(attribute: string): {[ key: string ]: boolean}
attributeRequired
name of the property to retrieve.
getList
public getList(attribute: string): string[]
attributeRequired
name of the property to retrieve.
getMap
public getMap(attribute: string): {[ key: string ]: any}
attributeRequired
name of the property to retrieve.
getNumber
public getNumber(attribute: string): number
attributeRequired
name of the property to retrieve.
getNumberList
public getNumberList(attribute: string): number[]
attributeRequired
name of the property to retrieve.
getNumberMap
public getNumberMap(attribute: string): {[ key: string ]: number}
attributeRequired
name of the property to retrieve.
getString
public getString(attribute: string): string
attributeRequired
name of the property to retrieve.
getStringMap
public getStringMap(attribute: string): {[ key: string ]: string}
attributeRequired
name of the property to retrieve.
keys
public 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.
pluckProperty
public pluckProperty(property: string): 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
The property of the iterators values to map to.
values
public 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
| Name | Description |
|---|
fromComplexList | Creates a new iterator from a complex list. |
fromDataSources | Creates a new iterator from a data source that has been created with the for_each argument. |
fromList | Creates a new iterator from a list. |
fromMap | Creates a new iterator from a map. |
fromResources | Creates a new iterator from a resource that has been created with the for_each argument. |
fromComplexList
import { ResourceTerraformIterator } from 'cdktn'
ResourceTerraformIterator.fromComplexList(list: IResolvable | ComplexList | StringMapList | NumberMapList | BooleanMapList | AnyMapList, mapKeyAttributeName: string)
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
const cert = new AcmCertificate(this, "cert", {
domainName: "example.com",
validationMethod: "DNS",
});
const dvoIterator = TerraformIterator.fromComplexList(
cert.domainValidationOptions,
"domain_name"
);
new Route53Record(this, "record", {
allowOverwrite: true,
name: dvoIterator.getString("name"),
records: [dvoIterator.getString("record")],
ttl: 60,
type: dvoIterator.getString("type"),
zoneId: Token.asString(dataAwsRoute53ZoneExample.zoneId),
forEach: dvoIterator,
});
listRequired
the list to iterate over.
mapKeyAttributeNameRequired
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.
fromDataSources
import { ResourceTerraformIterator } from 'cdktn'
ResourceTerraformIterator.fromDataSources(resource: ITerraformResource)
Creates a new iterator from a data source that has been created with the for_each argument.
resourceRequired
fromList
import { ResourceTerraformIterator } from 'cdktn'
ResourceTerraformIterator.fromList(list: string[] | IResolvable | number[] | (boolean | IResolvable)[])
Creates a new iterator from a list.
listRequired
fromMap
import { ResourceTerraformIterator } from 'cdktn'
ResourceTerraformIterator.fromMap(map: ComplexMap | {[ key: string ]: any} | {[ key: string ]: string} | {[ key: string ]: number} | {[ key: string ]: boolean})
Creates a new iterator from a map.
mapRequired
- Type: ComplexMap | {[ key: string ]: any} | {[ key: string ]: string} | {[ key: string ]: number} | {[ key: string ]: boolean}
fromResources
import { ResourceTerraformIterator } from 'cdktn'
ResourceTerraformIterator.fromResources(resource: ITerraformResource)
Creates a new iterator from a resource that has been created with the for_each argument.
resourceRequired
Properties
| Name | Type | Description |
|---|
key | any | Returns the current entry in the list or set that is being iterated over. |
value | any | Returns the value of the current item iterated over. |
keyRequired
public readonly key: any;
Returns the current entry in the list or set that is being iterated over.
For lists this is the same as iterator.value. If you need the index,
use count via TerraformCount:
https://developer.hashicorp.com/terraform/cdktf/concepts/iterators#using-count
valueRequired
public readonly value: any;
Returns the value of the current item iterated over.