aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.35k stars 3.76k forks source link

cloudformation-include: Support Fn::ForEach #27315

Open alFReD-NSH opened 9 months ago

alFReD-NSH commented 9 months ago

Describe the feature

cloudformation-include fails when a template with Fn::Foreach resource is passed as it tries to convert it to a CfnResource, but it's not exactly a resource so it doesn't have a type property:

jsii.errors.JavaScriptError:
  Error: The `type` property is required
      at new CfnResource (C:\Users\483413\AppData\Local\Temp\2\jsii-kernel-d3l9Pa\node_modules\aws-cdk-lib\core\lib\cfn-resource.js:1:1194)
      at CfnInclude.getOrCreateResource (C:\Users\483413\AppData\Local\Temp\2\jsii-kernel-d3l9Pa\node_modules\aws-cdk-lib\cloudformation-include\lib\cfn-include.js:1:13061)
      at new CfnInclude (C:\Users\483413\AppData\Local\Temp\2\jsii-kernel-d3l9Pa\node_modules\aws-cdk-lib\cloudformation-include\lib\cfn-include.js:1:2011)
      at Kernel._Kernel_create (C:\Users\483413\AppData\Local\Temp\2\tmpdsxxbqtf\lib\program.js:10071:25)
      at Kernel.create (C:\Users\483413\AppData\Local\Temp\2\tmpdsxxbqtf\lib\program.js:9742:93)
      at KernelHost.processRequest (C:\Users\483413\AppData\Local\Temp\2\tmpdsxxbqtf\lib\program.js:11658:36)
      at KernelHost.run (C:\Users\483413\AppData\Local\Temp\2\tmpdsxxbqtf\lib\program.js:11618:22)
      at Immediate._onImmediate (C:\Users\483413\AppData\Local\Temp\2\tmpdsxxbqtf\lib\program.js:11619:46)
      at processImmediate (node:internal/timers:466:21)

Use Case

Trying to use Fn::ForEach in cloudformation to create multiple resources based on custom resource output and bring that to my CDK stack but cloudformation-include.CfnInclude doesn't support Fn::ForEach.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

v2.98.0

Environment details (OS name and version, etc.)

any

khushail commented 9 months ago

Hi @alFReD-NSH ,thanks for reporting this.