Important — We recommend using Amazon or partner-provided AMIs. We advise against prebaking AMIs, because they incur an additional maintenance cost.

Do not hardcode AMIs. Instead, use AMI mappings in your AWS CloudFormation template. We’ve developed a standard format for AMI mappings that enables our tools to automatically update AMIs in all regions. To implement this format, create a subsection called AWSAMIRegionMap in the Mappings section of your template, and add all regions and their corresponding AMIs to this subsection. Here’s an example:

...
"Mappings": {
    "AWSAMIRegionMap": {
        "AMI": {
            "US1404HVM": "ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20160627",
            "WS2012R2": "Windows_Server-2012-R2_RTM-English-64Bit-Base-2016.08.11"
        },
        "ap-northeast-1": {
            "US1404HVM": "ami-2e63924f",
            "WS2012R2": "ami-281ad849"
        },
        "ap-northeast-2": {
            "US1404HVM": "ami-979258f9",
            "WS2012R2": "ami-ab549ec5"
        },
        "ap-south-1": {
            "US1404HVM": "ami-4a90fa25",
            "WS2012R2": "ami-4b7d0824"
        },
        "ap-southeast-1": {
            "US1404HVM": "ami-ea2bf989",
            "WS2012R2": "ami-d6f32ab5"
        },
        "ap-southeast-2": {
            "US1404HVM": "ami-396a415a",
            "WS2012R2": "ami-47bf8b24"
        },
        "eu-central-1": {
            "US1404HVM": "ami-4bd03b24",
            "WS2012R2": "ami-1db84972"
        },
        "eu-west-1": {
            "US1404HVM": "ami-02b62c71",
            "WS2012R2": "ami-a8592cdb"
        },
        "us-east-1": {
            "US1404HVM": "ami-2d39803a",
            "WS2012R2": "ami-bd3ba0aa"
        },
        "us-west-1": {
            "US1404HVM": "ami-992661f9",
            "WS2012R2": "ami-69febd09"
        },
        "us-west-2": {
            "US1404HVM": "ami-42569022",
            "WS2012R2": "ami-1712d877"
        }
    }
},
...

In this example, the AMI section contains the name of a specific type of AMI: WS2012R2 is set to Windows_Server-2012-R2_RTM-English-64Bit-Base-2016.08.11. Therefore, all WS2012R2 AMIs in the name-value pairs are set to this version. Two regions cannot have different AMI names for the same type of AMI. Also, all AMI types are associated with a codename.

Contact us at quickstart@amazon.com to understand which AMI type you wish to use so we can ensure that it’s in our codenames list.