I need to pass a list of cidr blocks to a module in the form of ["0.0.0.0/23","0.0.0.1/23",...] etc.
I have two cidr blocks which I'm getting from a subnet data source, which I can reference as an example as:
cidr_blocks = [data.aws_subnet.subnet1.id,data.aws_subnet.subnet2.id]
I also have a variable, depending on the environment, has a specific list of cidr_blocks to pass in, set as an example:
custom_cidrs = [""0.0.0.0/23","0.0.0.1/23","0.0.0.2/23"]
What I want to do is in the module, concat all these cidrs together to create one list. I have tried a few different things, including concat and list(). I just can't get the syntax right.
For some contexts, they'll be no custom cidr blocks to set, only the subnet cidrs, so in that instance my custom cidrs will be set to:
custom_cidrs = []
Any help on how to concat the two outputs and the custom list into one will be appreciated.
I'm thinking I may have to create a list from the two outputs first, then concat the two lists together, but not entirely sure. Can I do it in one command?
I am using terraform version 0.12.28
concatbut you mentioned it didn't work and it's hard to see why without seeing what you tried and the error you got.