How to supply a list of values to a Cfn property #23886
-
Hello, I'm trying to supply a list of values to this L1 CFN construct: Specifically, I'd like to use a Custom Resource to get a list of Account IDs, and feed it into the Any ideas? I'm using the latest TypeScript CDK. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Answer: CloudFormation doesn't allow you to reference an array value returned by a custom resource - you have to specify the specific indeces in the array that you want to reference. So unfortunately, if you want to feed it into an array, you will need to create that array in code, and specify each exact property you need. If this list is of an arbitrary length, you'll want to implement your own script which fetches the context you need instead of using a custom resource. See Commit cdk.context.json for more information: If you need some value (from AWS or elsewhere) for which there is no native CDK context provider, we recommend writing a separate script. The script should retrieve the value and write it to a file, then read that file in your CDK app. Run the script only when you want to refresh the stored value, not as part of your regular build process. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Answer: CloudFormation doesn't allow you to reference an array value returned by a custom resource - you have to specify the specific indeces in the array that you want to reference. So unfortunately, if you want to feed it into an array, you will need to create that array in code, and specify each exact property you need. If this list is of an arbitrary length, you'll want to implement your own script which fetches the context you need instead of using a custom resource. See Commit cdk.context.json for more information:
If you need some value (from AWS or elsewhere) for which there is no native CDK context provider, we recommend writing a separate script. The script should retrieve the v…