Class TerraformIterator
- All Implemented Interfaces:
ITerraformIterator
,software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
ListTerraformIterator
,MapTerraformIterator
,ResourceTerraformIterator
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface com.hashicorp.cdktf.ITerraformIterator
ITerraformIterator.Jsii$Default
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
TerraformIterator
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
TerraformIterator
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescription(experimental) Creates a dynamic expression that can be used to loop over this iterator in a dynamic block.forExpressionForList
(Object expression) (experimental) Creates a for expression that results in a list.forExpressionForMap
(Object keyExpression, Object valueExpression) (experimental) Creates a for expression that results in a map.static DynamicListTerraformIterator
fromComplexList
(Object list, String mapKeyAttributeName) (experimental) Creates a new iterator from a complex list.static ResourceTerraformIterator
fromDataSources
(ITerraformResource resource) (experimental) Creates a new iterator from a data source that has been created with thefor_each
argument.static ListTerraformIterator
(experimental) Creates a new iterator from a list.static MapTerraformIterator
(experimental) Creates a new iterator from a map.static ResourceTerraformIterator
fromResources
(ITerraformResource resource) (experimental) Creates a new iterator from a resource that has been created with thefor_each
argument.getBoolean
(String attribute) getBooleanMap
(String attribute) getNumberList
(String attribute) getNumberMap
(String attribute) getStringMap
(String attribute) keys()
(experimental) Creates a for expression that maps the iterators to its keys.pluckProperty
(String property) (experimental) Creates a for expression that accesses the key on each element of the iterator.values()
(experimental) Creates a for expression that maps the iterators to its value in case it is a map.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
TerraformIterator
protected TerraformIterator(software.amazon.jsii.JsiiObjectRef objRef) -
TerraformIterator
protected TerraformIterator(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
TerraformIterator
@Stability(Experimental) protected TerraformIterator()
-
-
Method Details
-
fromComplexList
@Stability(Experimental) @NotNull public static DynamicListTerraformIterator fromComplexList(@NotNull Object list, @NotNull String mapKeyAttributeName) (experimental) 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, });
- Parameters:
list
- the list to iterate over. This parameter is required.mapKeyAttributeName
- the name of the attribute that should be used as the key in the map. This parameter is required.
-
fromDataSources
@Stability(Experimental) @NotNull public static ResourceTerraformIterator fromDataSources(@NotNull ITerraformResource resource) (experimental) Creates a new iterator from a data source that has been created with thefor_each
argument.- Parameters:
resource
- This parameter is required.
-
fromList
@Stability(Experimental) @NotNull public static ListTerraformIterator fromList(@NotNull Object list) (experimental) Creates a new iterator from a list.- Parameters:
list
- This parameter is required.
-
fromMap
(experimental) Creates a new iterator from a map.- Parameters:
map
- This parameter is required.
-
fromResources
@Stability(Experimental) @NotNull public static ResourceTerraformIterator fromResources(@NotNull ITerraformResource resource) (experimental) Creates a new iterator from a resource that has been created with thefor_each
argument.- Parameters:
resource
- This parameter is required.
-
dynamic
@Stability(Experimental) @NotNull public IResolvable dynamic(@NotNull Map<String, Object> attributes) (experimental) 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- Parameters:
attributes
- This parameter is required.
-
forExpressionForList
@Stability(Experimental) @NotNull public IResolvable forExpressionForList(@NotNull Object expression) (experimental) 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
.- Parameters:
expression
- The expression to use in the for mapping. This parameter is required.
-
forExpressionForMap
@Stability(Experimental) @NotNull public IResolvable forExpressionForMap(@NotNull Object keyExpression, @NotNull Object valueExpression) (experimental) 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
.- Parameters:
keyExpression
- The expression to use as key in the for mapping. This parameter is required.valueExpression
- The expression to use as value in the for mapping. This parameter is required.
-
getAny
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as any
-
getAnyMap
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a map of any
-
getBoolean
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a boolean
-
getBooleanMap
@Stability(Experimental) @NotNull public Map<String,Boolean> getBooleanMap(@NotNull String attribute) - Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a map of booleans
-
getList
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a (string) list
-
getMap
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a map
-
getNumber
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a number
-
getNumberList
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a number list
-
getNumberMap
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a map of numbers
-
getString
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a string
-
getStringMap
- Parameters:
attribute
- name of the property to retrieve. This parameter is required.- Returns:
- the given attribute of the current item iterated over as a map of strings
-
keys
(experimental) 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
(experimental) 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
.- Parameters:
property
- The property of the iterators values to map to. This parameter is required.
-
values
(experimental) 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
.
-