- AWS CloudFormation is a service that gives developers and businesses an easy way to create a collection of related AWS resources and provision them in an orderly and predictable fashion.
- AWS CloudFormation introduces two concepts: The template, a JSON or YAML-format, text-based file that describes all the AWS resources you need to deploy to run your application and the stack, the set of AWS resources that are created and managed as a single unit when AWS CloudFormation instantiates a template.
- AWS CloudFormation does not get in the way; you retain full control of all elements of your infrastructure
- You can assign logical names to AWS resources in a template. When a stack is created, AWS CloudFormation binds the logical name to the name of the corresponding actual AWS resource
- Yes. AWS CloudFormation provides a set of application bootstrapping scripts that enable you to install packages, files, and services on your EC2 instances by simply describing them in your CloudFormation template
- YOU DON’T NEED to figure out the order for provisioning AWS services or the subtitles of making those dependencies work. CloudFormation takes care of this for you
- After the AWS resources are deployed, you can modify and update them in a controlled and predictable way, in effect applying version control to your AWS infrastructure the same way you do with your software
- CloudFormation templates are in the JSON format or YAML
- Exemple of a simple Template:
- You can use Fn:GetAtt to output data
- A StackSet is a container for AWS CloudFormation stacks that lets you provision stacks across AWS accounts and regions by using a single AWS CloudFormation template.
- Possible to Have Nested Cloud Formation Templates
- If you already have AWS resources running, the CloudFormer tool can create a template from your existing resources. This means you can capture and redeploy applications you already have running.
- By default, the “automatic rollback on error” feature is enabled
- You are charged for errors
- CloudFormation is free
- Stacks can wait for applications to be provisioned using the “WaitCondition”
- Route53 is completely supported. This includes creating new hosted zones or updating existing ones
- IAM Role creation and Assignment is also supported
- IT can be used with Chef an Puppet
- By default, the “automatic rollback on error” feature is enabled. This will cause all AWS resources that AWS CloudFormation created successfully for a stack up to the point where an error occurred to be deleted
- AWS CloudFormation provides a WaitCondition resource that acts as a barrier, blocking the creation of other resources until a completion signal is received from an external source such as your application, or management system.
- AWS CloudFormation allows you to define deletion policies for resources in the template. You can specify that snapshots be created for Amazon EBS volumes or Amazon RDS database instances before they are deleted. You can also specify that a resource should be preserved and not deleted when the stack is deleted
- There is no additional charge for AWS CloudFormation. You only pay for the AWS resources that are created (e.g., Amazon EC2 instances, Elastic Load Balancing load balancers etc.)
- Charges for AWS resources created during template instantiation apply irrespective of whether the stack as a whole could be created successfully or not.
- There are no limits to the number of templates. Each AWS CloudFormation account is limited to a maximum of 200 stacks
- You can include up to 60 parameters and 60 outputs in a template.
- The parameters property type in CloudFormation allows you to accept user input when starting the template, allowing you to reference the user input as variable throughout your Cloud Formation template
- “Ruby Statement” cannot be used inside a CloudFormation Template, but “Intrinsic Function” are allowed
- By default, you ay have 200 CloudFormation Stacks, to increase need to contact AWS. unlimited number of Templates
- When a CloudFormation stack encounters an error during creation you will see ROLLBACK_IN_PROGRESS status message
- CloudFormation Template Anatomy
- You can use the FN::FindInMap function to return a named value based on a specified key
- Possible to use regular expressions in CloudFormation templates
- API to list resources that belong to a CloudFormation Stack : DescribeStackResources
- You can use intrinsic functions only in a specific parts of a template. Currently, you can use intrinstic functions in resource properties, outputs, metadata attrs and update policy attributes. You can also use intrinsic functions to conditionally create stack resources
- AWS CloudFormation provides a set of Python helper scripts that you can use to install software and start services on an amazon EC2 instance that you create as part of your stack
- list-stacks: all stacks even those deleted
- describe-stacks: running stacks
- If you use AWS::EC2::KeyPair::KeyName parameter type, AWS CloudFormation validates the input value against users existing key pair names before it creates any resources
- Fn::Select function used to retrieve an object from a set of objects
- The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.
- The intrinsic function Ref returns the value of the specified parameter or resource.
- The intrinsic function Fn::ImportValue returns the value of an output exported by another stack.