Skip to content

Allow iterators to handle sets of anything #2731

Open
@rivatove

Description

@rivatove

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

At this moment, it's not possible to use forEach with certain arguments, despite their availability in HCL, e.g.

  • Set of numbers (result of Fn.range)
  • Nested sets (result of Fn.chunk)

They are standard library functions and it makes little sense that they can't be used for iteration.

Workaround (Fn.chunk):

const chunkList = Fn.chunklist(value, chunkSize)
const iterator = new ListTerraformIterator(Fn.slice([...Array(100).keys()].map(v => v.toString()), 0, Fn.lengthOf(chunkList)))
...
Fn.element(chunkList, iterator.value)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/has-workaroundA bug with a workaround (may not be elegant)cdktfenhancementNew feature or requestfeature/iteratorshelp wantedCommunity contributions welcome as the core team is unlikely to work on this soonpriority/backlogLow priority (though possibly still important). Unlikely to be worked on within the next 6 months.size/smallestimated < 1 day

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions