Skip to content

custom-resources: How to iterate over list returned by custom resource #22826

Discussion options

You must be logged in to vote

There isn't a good solution here, I think the easiest, best solution we have is as follows for a list of arbitrary length:

Forego the custom resource entirely. Instead you will first write a shell script that retrieves the list and writes it to a JSON file. Then, read that JSON file in your cdk app and do the loop there

There are a number of problems with this however. Namely, the list cannot be deployed as part of your app - it has to be deployed before you synth. Additionally, if the list ever changes you will need to manually invalidate it. And lastly, if you need to do this in multiple accounts then you need to do have credentials to all of them during synth

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tiagolisalves
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by peterwoodworth
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #22778 on November 08, 2022 03:30.