CloudFormation Flashcards
What is CloudFormation?
- Infrastructure as Code
- Code that can be deployed and is written to create / update / delete infrastructure
Is there a cost for using CloudFormation?
No. Only the underlying services.
High Level - How does CloudFormation work?
- Templates have to be uploaded in S3 and then referenced in CloudFormation.
- To update a template, a new version must be uploaded to AWS (cannot edit existing one directly).
What are the 2 main ways to deploy CloudFormation templates?
- Manually
- Automated (recommended)
Describe manual deploys in CloudFormation
- Edit templates in the CloudFormation designer
- Use the console to input parameters etc.
Describe the high level overview of deploying CloudFormation through automation.
- Edit templates in a YAML file.
- Use the AWS CLI to deploy the templates.
- Recommended way in order to fully automate flow.
List the 6 main building blocks for CloudFormation.
- Resources (Required)
- Parameters
- Mappings
- Outputs
- Conditionals
- Metadata
The exam will not expect you to write CloudFormation templates, but it will expect you to be able to READ CloudFormation templates. What language should you be familar with so that you can read and understand CloudFormation?
YAML
Can Resources be dynamically created using CloudFormation?
No. Resources in the CloudFormation Template must be declared.
Is every AWS resource supported through CloudFormation.
No, but almost. Mostly smaller services that are not yet addressed and you can work around that using AWS Lambda Custom Resources.
What are CloudFormation parameters?
- Parameters are a way to provide inputs to your AWS CloudFormation templates.
- Parameters are extremely powerful, controlled, and can prevent errors from happening in your templates thats to types.
When should you use CloudFormation parameters?
- If the CloudFormation resource is likely to change in the future.
- By making a parameter you will not have to re-load a template to change its content.
How do you reference a parameter in CloudFormation?
- The Fn::Ref function can be leverage to reference parameters.
- The shorthand for this in YAML is !Ref
- Parameters can be referenced anywhere in the template.
How can you get the account ID using a CloudFormation template?
- CloudFormation has something called pseudo parameters.
- These can be used at anytime and are enabled by default.
- One of these pseudo parameters in AWS::AccountId
What are CloudFormation Mappings?
- Mapping are fixed variables with the CloudFormation template.
- Handy to differentiate between different environments (dev vs prod), regions, AMI types etc.
- All values are hardcoded in the template.
What is the difference between CloudFormation parameters & mappings?
Use Mapping when you know values in advanced and reosurces will most likely NOT change. Those values can be turned into variables (region, AMI, enviroment etc. ).
Use Parameters when a resource configuration is likely to change in the future.
What happens if you delete a stack created by CloudFormation?
Deleting a stack deletes every single artifact that was created by
CloudFormation.
How are CloudFormation stacks identified?
Stacks are identified by a name.
What are CloudFormation outputs?
- The outputs section in a CloudFormation template declares optional outputs that must first be exported and then can be imported into other stacks.
- Allows for collaboration across stacks.
What happens if you delete a stack that has declared exported outputs?
That stack cannot be deleted as long as exported outputs are being used in other stacks.
What is a CloudFormation Cross Stack Reference?
When a stack references the output(s) of another stack.
How are CloudFormation outputs imported into another stack?
- Fn::ImportValue
- In YAML this is : !ImportValue [Value Variable Name]
How are conditions used in CloudFormation?
- Conditions are used to control the create of resources or outputs.
- Example: Conditions can be based on Environment, Region etc.
Hoe are conditions defined in CloudFormation?
There is a conditions section the YAML file that can use any common logical operators.