Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-cdk-lib.Fn): Support Fn::ForEach #27211

Open
1 of 2 tasks
faridnsh opened this issue Sep 20, 2023 · 9 comments
Open
1 of 2 tasks

(aws-cdk-lib.Fn): Support Fn::ForEach #27211

faridnsh opened this issue Sep 20, 2023 · 9 comments
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1

Comments

@faridnsh
Copy link

Describe the feature

Fn::ForEach is a new function that is added to cloudformation.

Use Case

Creating multiple resources based on Cloudformation template parameter. I'm deploying CDK generated templates to Service Cataloge.

Proposed Solution

ForEach function in aws-cdk-lib.Fn

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.96.2

Environment details (OS name and version, etc.)

Any

@faridnsh faridnsh added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2023
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Sep 20, 2023
@pahud
Copy link
Contributor

pahud commented Sep 20, 2023

Thank you for the feature request and PR! This is an awesome feature!

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2023
@faridnsh
Copy link
Author

Giving this more thoughts, we'll have to think off how the interface would be. This could be applied to resources, conditions and outputs.

@faridnsh
Copy link
Author

faridnsh commented Sep 27, 2023

Here's two different possibilities, we could create resources for it:

  1. Inside a callback function, which makes it somewhat functional programming looking:
    new ForEach(this, 'Queues', queueNames, (scope: Construct, variable: string)  => {
        new sqs.Queue(scope, 'Test', {
            queueName: Token.asString(variable)
        })
    });
  1. Or use the class properties:
    const forEach = new ForEach(this, 'Queues', queueNames);
    new sqs.Queue(forEach.childrenScope, 'Test', {
      queueName: Token.asString(forEach.identifier)
    });

It would be nice to gather more input from CDK core members.

@matheushent
Copy link

This feature request is open for quite a while... any prevision on when it is coming?

@erikrj
Copy link

erikrj commented Jul 22, 2024

This is a feature we would really like to see. We have stacks that fetch parameters in remote regions using an AwsCustomResource and we want to be able to do Fn.split and then Fn.forEach to loop over them when CloudFormation executes.

@moelasmar moelasmar added @aws-cdk/core Related to core CDK functionality and removed aws-cdk-lib Related to the aws-cdk-lib package labels Aug 28, 2024
@matheushent
Copy link

matheushent commented Sep 27, 2024

This is such a key to our business nowadays. It would be good if this gets prioritized. For us, we want to iterate over a parameter whose type is a list

@jaecktec
Copy link
Contributor

hey @faridnsh , I personnally am in favour of the first suggestion. It feels more typescripty and less yamlish.

@matheushent
Copy link

matheushent commented Nov 8, 2024

hey @faridnsh , I personnally am in favour of the first suggestion. It feels more typescripty and less yamlish.

The first suggestion is indeed more typescripty and that's precisely why it shouldn't be implemented that way. We have to note that CDK is used in many languages, and, IMO, it should have a good experience in all of them :)

@automartin5000
Copy link

This is a feature we would really like to see. We have stacks that fetch parameters in remote regions using an AwsCustomResource and we want to be able to do Fn.split and then Fn.forEach to loop over them when CloudFormation executes.

Have the same use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

No branches or pull requests

7 participants