18. CloudFormation Flashcards
What are the CloudFormation template components?
- Resources (MANDATORY)
- Parameters
- Mappings
- Outputs
- Conditionals
- Metadata
What are CloudFormation parameters?
Parameters are a way to provide inputs to your CloudFormation template. They’re important for when you want to REUSE templates across the company
Can you create a dynamic amount of resources using CloudFormation?
No. Everything in the CloudFormation template has to be declared. You can’t perform code generation there
How do you reference a parameter in CloudFormation?
Fn::Ref
!Ref in YAML
What are CloudFormation mappings?
Mappings are fixed variables within your CloudFormation Template. They’re handy to differentiate between different environments (dev vs prod). All the values are hardcoded within the template
How do you reference a mapping in CloudFormation?
Fn::FindInMap
!FindInMap in YAML
How do you reference an attribute in CloudFormation?
Fn::GetAtt
What is the default CloudFormation Rollback for stack creation failure?
Everything rolls back (gets deleted)
- we can look at the log
- option to disable rollback and troubleshoot what happened
What is the default CloudFormation Rollback for stack update failure?
The stack will automatically rollback to the previous known working state
- ability to see in the log what happened and error messages
What do you use to create, update, or delete stacks across multiple accounts and regions with a single operation?
CloudFormation StackSets
- administrator account to create StackSets
- when you update a stack set, all associated stack instances are updated throughout all accounts and regions
Which section of a CloudFormation template does not allow for conditions?
Parameters
Parameters enable you to input custom values to your CloudFormation template each time you create or update a stack.
Exported Output Values in CloudFormation must have unique names:
a. within a single Region
b. across all Regions
Exported Output Values in CloudFormation must have unique names within a single Region
When are CF cross stacks helpful?
- when stacks have different life cycles
- when you need to pass export values to many stacks (VPC ID, etc)
Cross stacks use Outputs Export and Fn::ImportValue
When are CF nested stacks helpful?
- when components must be reused (ex: reuse how to properly configure an ALB)
- the nested stack is only important to the higher level stack (it’s not shared)