Link Search Menu Expand Document

Table of contents

Mappings

The Mappings section matches a key to a corresponding set of named values

Info on Mappings from AWS can be found here

You can create a set of mappings by invoking the mappings() function

All Values are the Value<T> type, see The Value<T> Type

mappings(
        "RegionMap" to mapOf(
                "us-east-1" to mapOf(
                        "HVM64" to +"ami-0ff8a91507f77f867",
                        "HVMG2" to +"ami-0a584ac55a7631c0c"
                ),
                "us-west-1" to mapOf(
                        "HVM64" to +"ami-0bdb828fd58c52235",
                        "HVMG2" to +"ami-066ee5fd4a9ef77f1"
                )
        )
)

A map lookup can be done by passing an instance of FindInMap

instance {
    instanceType("m1.small")
    imageId(FindInMap(+"RegionMap", awsRegion, +"HVM64"))
}

Produces the following Template

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"