AWS CloudFormation Flashcards
(35 cards)
CloudFormation
Declarative way of outlining your AWS infrastructure for any resources via template
Clouformation resources
Represent the different AWS components that will be created and configured, mandatory in template
CloudFormation parameters
Way to provide inputs to your template, if config will change in future you should make it a parameter
AllowedValues parameter
eg. use to specify what EC2 instance type is allowed
NoEcho parameter
NoEcho: true means the value will not be displayed anywhere eg. in logs
Syntax for parameters
Use Fn::Ref or !Ref in YAML to reference parameters
Pseudo parameters
set parameters eg. AWS::Region to get the region
Mappings
Fixed variables within the template, good for differentiating between different environments, regions ,etc
Mappings vs Parameters
Use mappings when you know in advance all the values that can be taken and can be deduced from things like region and AZ, use parameters when the values are user specific
Outputs
Declare optional output values that we can import into other stacks, view in AWS console of CLI
How to reference output from another stack
Use Fn::ImportValue or !ImportValue
True or false? You can delete the underlying stack without deleting the underlying references
False
CloudFormation conditions
Common use case us dev / test / prod, use different resources depending on environment
Fn::Ref
Can reference parameters or resources, shorthand is !Ref in YAML
Fn::GetAtt
Get attributes for your resources eg. AZ, Id, PrivateIp
Fn::FindInMap
Return a named value from a specific key
Fn::ImportValue
Import values that are exported in other stacks
Fn::Base64
Convert string to base64, used to pass encoded data to EC2’s UserData property
In the case that stack creation fails …
Default is that everything rolls back (gets deleted), option to disable rollback and troubleshoot what happened
Service role
IAM role that allows CloudFormation to create/update/delete stack resources on your behalf
CAPABILITY_NAMED_IAM and CAPABILITY_IAM
Need to give to cloudformation when template is going to update IAM resources
CAPABILITY_AUTO_EXPAND
Necessary when your CloudFormation template includes Macros of stacks within stacks
InsufficientCapabilitiesException
Exception that will be thrown by CloudFormation if capabilities haven’t been acknowledged when deploying a template (security measure)
DeletionPolicy
Control what happens when the CloudFormation template is deleted or when a resource is removed from a CloudFormation template