Main Menu
- Getting Started
- Course Introduction
- CloudFormation First Hands-On
- CloudFormation Parameters
- CloudFormation Resources
- CloudFormation Mappings
- CloudFormation Outputs
- CloudFormation Conditions
- CloudFormation Metadata
- CFN Init and EC2 User Data
- CloudFormation Advanced Topics
Getting Started
How to install Atom JSON/YAML editor in Ubuntu
sudo add-apt-repository ppa:webupd8team/atom sudo apt-get update sudo apt-get -y install atom
What is CloudFormation
- A declarative way of outlining your aWS Infrastructure for any resource
- Example, “I need”
- A Security Group
- 2 EC2 Instances
- 2 Elastic IPs for the instances
- An S3 bucket
- An ELB
- CloudFormation creates these for you, in the right order, with the exact configuration that you specify
Benefits of CloudFormation
- Infrastructure as code
- No manually created resources, great for control
- Code can be version controlled using GIT
- Changes are reviewed through code
- Cost
- Each resources with the stack are tagged with an identifier to easily see how much a stack costs
- You can estimate the cost of your resources using the template
- Savings: In Dev, you can automate deletion of a stack at 5:00pm and recreate safely at 8:00am
- Productivity
- Re-create and destroy infrastructure on the fly
- Automatic Diagram generation (What??? How Cool!)
- Declarative programming
- Separation of concern
- VPC stacks
- Network stacks
- App stacks
- Don’t reinvent the wheel
- Leverage existing templates
- Tweak as required
- Leverage the documentation
- Leverage existing templates
Code Download and Tools
- https://support.udemy.com/hc/en-us/articles/229604708-Downloading-Supplemental-Resources
- code-v2.zip
Introductory Examples
https://www.udemy.com/aws-cloudformation-master-class/learn/v4/t/lecture/8138960?start=0
- Adding a new Stack
- CloudFormation > [Create a new stack]
- Upload File
- Name Stack (Introduction)
- Stack names cannot be edited after creation!
- Add tags
- awe:cloudformation:logical-id
- aws:cloudformation:stack-id
- aws:cloudformation:stack-name
- [Create]
- CloudFormation will provision items in the correct order. You do not have to plan this out.
- CloudFormation > [Create a new stack]
- Changing an Existing Stack
- Upload the file
- Edit tags
- Preview will show you the changes
- Existing EC2 Instances that have been modified will be deleted and replaced.
- Delete a Stack
- CloudFormation > Select Stack > Actions > Delete Stack
- This will delete the entire stack (all services created with the script) in the correct order.
Summary
- Templates are uploaded in S3 and then referenced in CloudFormation
- You cannot edit previous templates. You must re-upload a new version.
- AWS will determine what changes, does not change, needs to be added or deleted, etc., and in the correct order.
- Stacks are identified by name, so use unique names
- Deleting a stack deletes every single artifact that was created by CloudFormation.
Quiz
- Which of the following is a benefit of using CloudFormation
- Infrastructure as Code
- Cost
- Productivity
- Separation of Concerns
- Don’t reinvent the wheel
- All of the above
- When we delete a CloudFormation stack, we have to delete everything that was created by it manually.
- Yes
- No
- Stacks must have unique names
- Yes
- No
- * All stacks are identified by name, per Region