AWS CloudFormation Template components

Kom i gang. Det er Gratis
eller tilmeld med din email adresse
AWS CloudFormation Template components af Mind Map: AWS CloudFormation Template components

1. Resources

1.1. Resources are the core of your CloudFormation template (MANDATORY)

1.2. form: AWS::aws-product-name::data-type-name

1.3. example: AWS::EC2::Instance

2. Mappings

2.1. Mappings are fixed variables within your CloudFormation Template

2.2. regions (AWS regions), AMI types, etc

2.3. get mapping value : !FindInMap [ MapName, TopLevelKey, SecondLevelKey ]

3. Functions

3.1. !Ref

3.1.1. function can be leveraged to reference parameter or refernce

3.2. !GetAtt

3.2.1. Attributes are attached to any resources you create

3.2.2. !GetAtt Ec2Instance.AvailabilityZone

3.3. FindInMap

3.4. !ImportValue

3.4.1. Import values that are exported in other templates

3.5. !Join

3.5.1. Join values with a delimiter

3.5.2. !Join [ ":", [a,b,c]]

3.6. !Sub

3.6.1. used to substitute variables from a text

3.7. Base64

3.7.1. We can have user data at EC2 instance launch through the console

3.7.2. log is in /var/log/cloud-init-output.log

4. Resource Attribute Reference

4.1. CreationPolicy

4.1.1. prevent its status from reaching create complete until AWS CloudFormation receives a specified number of success signals or the timeout period is exceeded.

4.1.2. so send signals to CFN use cfn-signal or SignalResource API

4.1.3. supported: AWS::AutoScaling::AutoScalingGroup, AWS::EC2::Instance, and AWS::CloudFormation::WaitCondition.

4.1.4. sample CreationPolicy: AutoScalingCreationPolicy: MinSuccessfulInstancesPercent: Integer ResourceSignal: Count: Integer Timeout: String

4.2. DeletionPolicy

4.2.1. With the DeletionPolicy attribute you can preserve or (in some cases) backup a resource when its stack is deleted

4.2.2. DeletionPolicy Options

4.2.2.1. Delete

4.2.2.2. Retain

4.2.2.3. Snapshot

4.2.2.3.1. support snapshots (AWS::EC2::Volume, AWS::ElastiCache::CacheCluster, AWS::ElastiCache::ReplicationGroup, AWS::Neptune::DBCluster, AWS::RDS::DBCluster, AWS::RDS::DBInstance, AWS::Redshift::Cluster)

4.3. DependsOn

4.3.1. With the DependsOn attribute you can specify that the creation of a specific resource follows another.

4.4. UpdatePolicy

4.4.1. It supports AWS::AutoScaling::AutoScalingGroup, AWS::ElastiCache::ReplicationGroup, AWS::Elasticsearch::Domain, or AWS::Lambda::Alias resources

4.5. UpdateReplacePolicy

4.5.1. Use the UpdateReplacePolicy attribute to retain or (in some cases) backup the existing physical instance of a resource when it is replaced during a stack update operation

4.5.2. Options

4.5.2.1. Delete

4.5.2.2. Retain

4.5.2.3. Snapshot

5. Outputs

5.1. output values can be imported to other stacks

5.2. you can’t delete a CloudFormation Stack if its outputs are being referenced by another CloudFormation stack

6. Metadata

6.1. AWS::CloudFormation::Designer

6.1.1. Describes how your resources are laid out in AWS CloudFormation Designer (Designer). Designer automatically adds this information when you use it to create and update templates.

6.2. AWS::CloudFormation::Interface

6.2.1. Defines the grouping and ordering of input parameters when they are displayed in the AWS CloudFormation console.

6.3. AWS::CloudFormation::Init

6.3.1. Defines configuration tasks for the cfn-init helper script. This script is useful for configuring and installing applications on EC2 instances

7. Parameters

7.1. used to provide input

7.2. Reference a Parameter use Fn::Ref or !Ref

7.3. attributes: Type, description, constrains, Min/Max length, Min/Max Value, defaults, Allowed values(array), allowedpattern(regexp), NoEcho

8. Conditionals

8.1. Conditions are used to control the creation of resources or outputs.

8.2. commonly used for environments parameters(dev, prod), regions, etc

8.3. !Equals, !And, !If, !Not, !Or

9. Helper Scripts

9.1. cfn-init

9.1.1. Use to retrieve and interpret resource metadata, install packages, create files, and start services

9.2. cfn-signal:

9.2.1. 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.

9.3. cfn-get-metadata:

9.3.1. Use to retrieve metadata for a resource or path to a specific key.

9.4. cfn-hup

9.4.1. Use to check for updates to metadata and execute custom hooks when changes are detected.