pirhac
pirhac

Reputation: 927

Terraform: dynamically create list of resources

Due to some prior decisions, there is a script that creates ALBs and a completely separate one to setup alarms for each ALB created (odd, but I can't change this).

I could hard code a list of all the ALBs and iterate thru them, ie:

albs = ['a', 'b']

I know how to iterate thru a list with a "for_each".

What I need is to build the list dynamically so I don't have to manually maintain the list. I know I can get a list of ALBs using:

terraform state list [options] ## https://www.terraform.io/docs/commands/state/list.html

but that doesn't really help (sure, I can pipe that to a file and iterate through the lines in the file and pass them as parameters - but that is ugly as sin)

How do I dynamically build the list with all my ALBs? Something like:

albs = state_list([options])

Thanks! Using AWS.

Upvotes: 0

Views: 878

Answers (0)

Related Questions