Table of contents
Find in Map
The Fn::FindInMap function in CloudFormation allows lookups from the mappings section.
Info on
Fn::FindInMapfrom AWS can be found here
KloudFormation provides the FindInMap class. Here is an example of looking up machine images based on region and AMI architecture:
val regionMappings = "RegionMap"
val usEast1 = "us-east-1"
val usWest1 = "us-west-1"
val hvm64 = "HVM64"
val hvmG2 = "HVMG2"
mappings(
regionMappings to mapOf(
usEast1 to mapOf(
hvm64 to +"ami-0ff8a91507f77f867",
hvmG2 to +"ami-0a584ac55a7631c0c"
),
usWest1 to mapOf(
hvm64 to +"ami-0bdb828fd58c52235",
hvmG2 to +"ami-066ee5fd4a9ef77f1"
)
)
)
instance {
instanceType("m1.small")
imageId(FindInMap(+regionMappings, awsRegion, +hvm64))
}
Produces
Mappings:
RegionMap:
us-east-1:
HVM64: "ami-0ff8a91507f77f867"
HVMG2: "ami-0a584ac55a7631c0c"
us-west-1:
HVM64: "ami-0bdb828fd58c52235"
HVMG2: "ami-066ee5fd4a9ef77f1"
Resources:
Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId:
Fn::FindInMap:
- "RegionMap"
- Ref: "AWS::Region"
- "HVM64"
InstanceType: "m1.small"