CFN is an Infrastructure as Code (IAC) product – you can create, manage, and remove infrastructure automatically.
CloudFormation (CFN)
Templates
A CFN template is JSON or YAML. It contains logical resources and configuration.
- A template can create up to 200 resources.
- The Resource section is mandatory.
- Optional sections: Metadata, Parameters, Mappings, Conditions, Transform, Outputs
Resources
Resources are identified with Resource type identifiers.
AWS::product::type
e.g.) AWS::EC2::Instance, AWS::IAM:Role, AWS::S3::Bucket
Stacks
Stacks are created and modified based on templates, which can be changed and used to update a stack.
- Stacks take logical resources from a template and create, update, or delete physical resources in AWS.
- If a stack is deleted, any resources it has created are also deleted.
- A stack can be updated by uploading a new version of a template.
- New logical resource -> New physical resource
- Removed logical resource -> causes the stack to delete physical resources.
- Changed logical resources -> some disruption or replace physical resources.
Benefits
- Quick deployment and Easy cleanup
- Allows to prepare for disaster recovery
- Infrastructure version control