I'm using CloudFormation to deploy an ELB to a pre-existing VPC which has pre-existing Subnets. I've listed the subnets in a Mappings section of the template and select the mapping based on the Environment parameter. This works fine if the Mapping is for a single value, but I want the Mapping to return a list as I want the ELB to be multi-AZ.
I've tried various combinations of the example below, but I always get the same error Value of property Subnets must be of type List of String
.
Is there a way that FindInMap can return a list of values?
Example ELB Config
"ElasticLoadBalancerAPI": {
"Properties": {
"ConnectionDrainingPolicy": {
"Enabled": true,
"Timeout": 30
},
"ConnectionSettings": {
"IdleTimeout": 60
},
"CrossZone": "false",
"Subnets" : [
{
"Fn::FindInMap": [
"AWSEnv2PublicSubnets",
{
"Ref": "Env"
},
"subList"
]
}
],
"SecurityGroups" : [ { "Ref" : "LoadBalancerSecurityGroup" }],
etc...
Example Parameters
"Parameters": {
"Env": {
"Description": "Environment",
"Type": "String",
"Default": "DEV",
"AllowedValues": [
"DEV",
"TEST"
]
}
}
Example Mappings
"Mappings": {
"AWSEnv2PublicSubnets": {
"DEV": {
"subList": ["subnet-1111","subnet-2222","subnet-3333"]
},
"TEST": {
"subList": ["subnet-4444"]
}
}
}