Introduction to AWS CloudFormation
- What is AWS CloudFormation?
- AWS CloudFormation is a service that allows you to manage, configure, and provision your AWS infrastructure using code.
- It enables you to define your infrastructure in a template file using either YAML or JSON format.
- CloudFormation automates the creation of resources in the correct order with the specified configuration.
- Benefits of Using AWS CloudFormation
- Infrastructure as Code: Ensures that resources are not created manually, allowing for better control and versioning using tools like Git.
- Cost Management: Resources within a CloudFormation stack are tagged, making it easy to track costs and estimate expenses from templates.
- Productivity: Enables quick creation and deletion of infrastructure, leveraging the cloud's elasticity to only pay for what you use.
- Automated Diagram Generation: Provides visual architecture diagrams through CloudFormation Designer.
- Declarative Programming: No need to manage the order of resource creation or orchestration, as CloudFormation handles it.
- Separation of Concerns: Allows for multiple stacks for different applications and layers, such as network and application stacks.
- Leverage Existing Templates: Utilize existing templates and documentation to expedite the creation of new CloudFormation templates.
- How CloudFormation Works
- Templates must be uploaded to Amazon S3 and then referenced in CloudFormation to create a stack.
- A CloudFormation stack is a collection of AWS resources defined in the template.
- A new version of the template must be uploaded to update a stack, and the stack will be updated accordingly.
- Stacks are identified by a name within an AWS region.
- Deleting a stack removes all resources that were created by it.
- Deploying CloudFormation Templates
- Manual Deployment: Use CloudFormation Designer or a code editor to create a template and the AWS console for parameters.
- Automated Deployment: Edit templates as YAML files and deploy using the command-line interface (CLI) or continuous delivery tools.
- Building Blocks of CloudFormation
- Template Format Version: Specifies the AWS template version.
- Description: Comments about the template.
- Resources: The core section defines the AWS resources in the template.
- Parameters: Dynamic inputs for the template.
- Mappings: Static variables for the template.
- Outputs: References to the created resources.
- Conditionals: Conditions for resource creation.
- Template Helpers: Includes references and functions.
The training will include detailed looks at these components and practical code examples.
If your template contains custom-named IAM resources, don't create multiple stacks reusing the same template. IAM resources must be globally unique within your account.
After you execute a change, AWS CloudFormation removes all change sets that are associated with the stack because they aren't applicable to the updated stack.
