AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Mappings

Mappings enable you to specify conditional parameter values in your template. When used with the intrinsic function Fn::FindInMap, it works like a Case statement or lookup table.

In the optional Mappings section, you define one or more mappings. Each mapping has a logical name unique within the template, and defines one or more key-attribute pairs. Each attribute must be a literal string or list of literal strings. You cannot base a mapping on a parameter, pseudo parameter, or intrinsic function. Along with declaring as many conditional mapping keys as you need, you can declare which mapping key is the default. The following example shows a Mappings section that declares a map with four selections, in which a region name is mapped to a specific Amazon Machine Image (AMI) name:

"Mappings" : {
"RegionMap" : {
    "us-east-1" : {
      "AMI" : "ami-76f0061f"
    },
    "us-west-1" : {
      "AMI" : "ami-655a0a20"
    },
    "eu-west-1" : {
      "AMI" : "ami-7fd4e10b"
    },
    "ap-southeast-1" : {
      "AMI" : "ami-72621c20"
    }
  }
}

When you want to assign a mapping attribute value to a resource property or output, you use the Fn::FindInMap function, passing it the logical name of the mapping, the mapping key name, and the mapping attribute name you want to retrieve. Specifying a parameter or pseudo parameter as the mapping key name you pass to Fn::FindInMap enables you to retrieve the right attribute value for use at runtime.

Two of the sample templates declare a Mappings section (see Example Templates). Also, for technical details about the Mappings section format, see Mappings Declaration.