Mappings are mapping a key to a set of values. Typical use case: defining a mapping between a region and an AMI.
- Create a CloudFormation template defining a mapping for AMIs based on the region.
- Create a CloudFormation stack based on your template.
- Open
stub.yaml
with an editor of your choice. The stub file contains a skeleton to start from. - Add a mappings section to your template (see Mappings section).
- Add a mapping named
RegionAMIMap
. The mapping should contain a region id as key,AmazonLinux
as name and the AMI id as value per region (see Mappings section)). - Use the mapping
RegionAMIMap
to define the AMI for the EC2 instance (see Mappings section) and Resource Type: EC2 instance.
ap-northeast-1 => ami-cbf90ecb
ap-southeast-1 => ami-68d8e93a
ap-southeast-2 => ami-fd9cecc7
eu-central-1 => ami-a8221fb5
eu-west-1 => ami-a10897d6
sa-east-1 => ami-b52890a8
us-east-1 => ami-1ecae776
us-west-1 => ami-d114f295
us-west-2 => ami-e7527ed7
- Open CloudFormation in AWS Management Console.
- Click Create Stack button.
- Select Upload a template to Amazon S3.
- Choose the template file you created for this lab.
- Click Next button.
- Insert
lab6-$username
as stack name. Replace$username
with your username (e.g. lab6-awittig). - Select a random subnet as parameter for Subnet.
- Select a random key as parameter for Key Pair.
- Insert
t2.micro
as parameter for InstanceType. - Insert
http://widdix.net/
or a website you own for URL. - Click Next button.
- Skip next step by clicking on Next button.
- Review your input and click Create button.
- Wait until your stack reaches status CREATE_COMPLETE.
- Select your stack by clicking on row of the table.
- Select Delete Stack from the Actions menu.
- Confirm the deletion of your stack.
- Congratulations! You are done with the lab!
This lab includes a sample solution sample-solution.yaml
. Use it if you are stuck during the creation of your template of if you want to review your results.