CloudFormation Template (CFT) Flashcards
Template sections
Format Version (optional)
Description (optional)
Metadata (optional)
Parameters (optional) ==> You can’t use conditions here
Mappings (optional)
Conditions (optional)
Transform (optional)
Resources (required)
Specifies the stack resources and their properties, such as an Amazon Elastic Compute Cloud instance or an Amazon Simple Storage Service bucket. You can refer to resources in the Resources and Outputs sections of the template.
Outputs (optional)
CloudFormation helper scripts
cfn-init: Use to retrieve and interpret resource metadata, install packages, create files, and start services.
cfn-signal: Use to signal with a CreationPolicy or WaitCondition, so you can synchronize other resources in the stack when the prerequisite resource or application is ready.
cfn-get-metadata: Use to retrieve metadata for a resource or path to a specific key.
cfn-hup: Use to check for updates to metadata and execute custom hooks when changes are detected.
Explain Fn::FindInMap
Find In Map Usage
Fn::FindInMap: [ MapName, TopLevelKey, SecondLevelKey ]
Resources:
myEC2Instance:
Type: “AWS::EC2::Instance”
Properties:
ImageId: !FindInMap
- RegionMap ==> Mapname
- !Ref ‘AWS::Region’ ==> TopLevelKey
- HVM64 ==> SecondLevelKey
InstanceType: m1.small
Why do we use Outputs Section
The optional Outputs section declares output values that you can import into other stacks (to create cross-stack references), return in response (to describe stack calls), or view on the AWS CloudFormation console.
For each AWS account, Export names must be unique within a region.