CloudFormation Flashcards
AWS CFT
describes all resources and their properties in JSON or YAML. It is recommended to write a template for each layer of architecture to minimize down-time.
Stack
is created on a successful execution of a template in CloudFormation, executing a template creates a defined set of AWS resources. a group of these AWS resources defined in CF is called a stack.
deletion policy
3 attributes: delete; retain; Snapshot.
Template structure
– AWSTemplateFormatVersion: optional, default is latest available format.
– Description: optional up to 1024 bytes. should be always next to the AWSTemplateForamtVersion.
– Metadata: optional. Init – defines the configuration or settings for the cfn-init helper scripts in the EC2 instance; Interface – helps to define the grouping and ordering for the input parameters. Designer – automatically added o the CFT when it is created using AWS CF Designer.
– Parameters: used to pass values into the template. maximum of 60 in a CFT.
– Mappings – values from parameters, pseudo parameters or intrinsic functions cannot be used.
– Conditions – can be modified only when resources are added, modified, or deleted.
transform;
– resources: where you create resources.
– Outputs:
best practice
use cross-stack reference to integrate resources from multiple templates into one template.
provide essential IAM privileges to the IAM user executing a CFT to create a stack.
reuse the whole or part of the template;
use nested stack to perform common template patterns.
not to embed credentials in any template.
use latest helper scripts.
before creating a stack, validate the template syntax.
stack resource modification should be carried out by modifying a template rather than directly performing the action.
Intrinsic Functions
Used to pass in values that are not available until run time. very practical when creating resources.
Fn::GetAttr – get attributes from a specified resources;
Fn::FindlinMap – returns value of a key from a specified mapping.
Fn::Join – Concatenates elements, separated by a specified delimiter;
Ref – Return a recource or value based on a logical name or parameter;
Fn:GetAZa – get the AZa for a specified region
Fn::Select - returns a single object from a list of objects by index.
You can only use intrinsic functions in specific parts of a template. You can use intrinsic functions in resource properties, metadata attributes, and update policy attributes.
CloudFormation Template specifies a public IP
appropriate for Bastion host. a domain controller, database server. and log collection server typically would not require a public IP address.
What is the default limit for CloudFormation templates per region?
There are no limits to the number of templates. but there is a limit of 200 stacks per AWS account. by default allows 20 stacks per region to be running at any given time.
Intrinsic Functions
You can only use intrinsic functions in specific parts of a template. You can use intrinsic functions in resource properties, metadata attributes, and update policy attributes.