Ref: https://learn.cantrill.io/courses/1820301/lectures/41301626
YouTube: https://www.youtube.com/watch?v=ptvce7lJ6Z0
DEMO: https://learn.cantrill.io/courses/1820301/lectures/41301627
IaC basics and AWS CloudFormation
- IaC = Infrastructure as Code
- Create, update & delete infrastructure using code and/or templates
- Code/Templates are consistent and repeatable
- Reduces human errors
- Much faster to provision/delete infrastructure than manually
- đź”§Â AWS CloudFormation (CFN) is the AWS official IaC product
- Templates written in YAML or JSON to interact with infrastructure inside AWS
- 💡 Nowadays very popular to use external IaC products like Terraform or CDK, which use/translate to AWS CFN templates to interact with AWS infrastructure
CFN Templates - Example and Components
- 💡 By default CFN templates are uploaded to an S3 bucket with prefix
CF
- ‼️ Despite the prefix, do NOT confuse CFN (CloudFormation) with CF (CloudFront)!!
- Template examples in YAML and JSON: https://github.com/acantril/aws-sa-associate-saac03/blob/main/0500-AWS_FUNDAMENTALS/00_LEARNINGAIDS/CloudWatchBasics-5.png
- Resources → AWS resources to create/update/delete
- e.g. VPCs, S3 buckets, EC2 instances…
- ‼️ This is the only component in a template that is mandatory!
- without resources, a template doesn't do anything
- âť—Â Resources listed in a template/stack are logical resources
- AWSTemplateFormatVersion → Version date of the template
- Description → Free text, can be used to describe what the template does
- âť—Â If description is provided, it must appear after
AWSTemplateFormatVersion
- Metadata → Controls how the template is shown in AWS UI
- Parameters → Fields that prompt the user for required information
- Mappings → Key-value pairs that can be used for lookups
- Conditions → Bind resources to specific conditions (”only do X if Y”)