Class TerraformIterator

java.lang.Object
software.amazon.jsii.JsiiObject
com.hashicorp.cdktf.TerraformIterator
All Implemented Interfaces:
ITerraformIterator, software.amazon.jsii.JsiiSerializable
Direct Known Subclasses:
ListTerraformIterator, MapTerraformIterator, ResourceTerraformIterator

@Generated(value="jsii-pacmak/1.93.0 (build 1706ca5)", date="2024-01-17T11:28:52.614Z") @Stability(Experimental) public abstract class TerraformIterator extends software.amazon.jsii.JsiiObject implements ITerraformIterator
  • 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 the for_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

      @Stability(Experimental) @NotNull public static MapTerraformIterator fromMap(@NotNull Object map)
      (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 the for_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

      @Stability(Experimental) @NotNull public IResolvable getAny(@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 any
    • getAnyMap

      @Stability(Experimental) @NotNull public Map<String,Object> getAnyMap(@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 any
    • getBoolean

      @Stability(Experimental) @NotNull public IResolvable getBoolean(@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 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

      @Stability(Experimental) @NotNull public List<String> getList(@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 (string) list
    • getMap

      @Stability(Experimental) @NotNull public Map<String,Object> getMap(@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
    • getNumber

      @Stability(Experimental) @NotNull public Number getNumber(@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 number
    • getNumberList

      @Stability(Experimental) @NotNull public List<Number> getNumberList(@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 number list
    • getNumberMap

      @Stability(Experimental) @NotNull public Map<String,Number> getNumberMap(@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 numbers
    • getString

      @Stability(Experimental) @NotNull public String getString(@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 string
    • getStringMap

      @Stability(Experimental) @NotNull public Map<String,String> getStringMap(@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 strings
    • keys

      @Stability(Experimental) @NotNull public IResolvable 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

      @Stability(Experimental) @NotNull public IResolvable pluckProperty(@NotNull String property)
      (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

      @Stability(Experimental) @NotNull public IResolvable 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.