Mappings

Mappings are hash tables, they can be referenced to perform searches by key name and retrieve specific values. We want our ec2-instance.yaml template to be portable across geographic regions but also to stay in compliance for the authorized corporate AMIs.

The full list of regions and AMIs with architectures is concise for brevity.

The pseudo function AWS::Region is used to replace the current region code into the function FindInMap call, this is specially useful to retrieve values, for example, account number.

The Fn::FindInMap function receives three parameters, the MapName, the TopLevelKey, and the SecondLevelKey. In this case, the function will be replaced with this values:

ImageId: !FindInMap [RegionMap, us-east-1, HVM64] 

And passed to the resource as:

ImageId: ami-0ff8a91507f77f867 

A completely refactored example is provided in the following link: https://github.com/gabanox/Certified-Solution-Architect-Associate-Guide/blob/master/chapter20/ec2-instance-full.yaml. Take your time to analyze it fully.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.102.166