Cloud Formation Flashcards
For cloud formation, describe the 3 stack update models:
- Update with no interruption
- Update with some interruption
- Replacement
Update w/No Interruption: Resource is updated with no interruption and no change to the physical ID, I.e.
Updating a resource profile
Update w/Some interruption: Resource encounters small disruption. Physical ID remains unchanged. I.e changing instance type for an EBS volume
Replacement: New resource with new physical id is created. Dependencies for other resources updated and old resource is deleted
What is the role of a stack update policy in Cloud Formation? How does the principal differ in a stack policy vs. other forms of policy?
A a stack update policy prevents specific updates to resources in a stack. It differs from other forms of policy in the sense that the principal is always *
Can you use cloud formation to estimate resource costs?
Yes
Can you edit an existing CloudFormation template?
No, you need to create a new version
When you delete a CloudFormation template, what happens to the resources created by that stack?
ALL resources created by a CF stack are deleted when the stack is deleted
What is the only mandatory thing in a CloudFormation stack?
Resources are the only mandatory part of a CF stack
How would you pass dynamic inputs to a CloudFormation stack?
You would use CloudFormation parameters
When you build a CloudFormation stack, do you need to specify the order in which they are created. For instance, if I want an EIP, do I need to specify that an EC2 instance needs to be created first and then have the EIP attached to it?
No. You do not need to specify the order in which to create resources in CloudFormation. Cloud formation will determine the correct order for resources to be created.
In your CloudFormation template you see the following line block of yaml:
ProductionEip:
Type: AWS::EC2::EIP
Properties:
InstanceId: !ref PublicHttpdServer
What is !ref?
!ref is a reference to a resource that is also created in the template. In this case it is an Ec2 instance called PublicHttpdServer
Can I create a dynamic amount of resources programatically in CloudFormation?
No. All resources need to be declared
How do I pass a value to a CloudFormation template?
You would use a cloud formation template parameter
I am building a CloudFormation template to provision load generators. This template has a security group restricting inbound ssh access to a clients static IP. Given that the set up of the generator is likely to be the same for client to client with the exception of the inbound static IP, what is the recommended way of achieving this so I don’t have to create new versions every time its updated?
You would create a CloudFormation parameter to read in the static IP when the template runs. For any resource configuration in CloudFormation you should use a parameter
Which function is used to reference parameters in CloudFormation?
Fn::Ref
Where can you reference parameters in a CloudFormation template?
Parameters can be referenced from anywhere in your CloudFormation template
What two classes of things can you reference using !ref in CloudFormation?
You can reference:
- Parameters
- Other resources created in the template
How would you reference you account ID, region or an SNS notification ARN within a CloudFormation template?
AWS provides Pseudo-parameters which allows you to access these values - i.e. !ref AWS::AccountId
I am building a CloudFormation template which needs to use specific AMI’s for each of the 3 regions it runs in, us-east-1, ap-southeast-2 and eu-west-1. What is the best way to specify the AMI for each of the regions
You should use Mappings within your template. These allow you to specify variables if they are known before hand, such as an AMI id.
How do mappings differ from parameters, why would you use one over the other?
You use parameters where values are very user specific and are not known beforehand. Mappings are used when you know in advance what the variables will be (think of them like Constants) or can be deduced from other variables (such as AZ, Region, AccountId)
What function do you use to access values from a MAPPING in a CloudFormation Template?
Fn::FindInMap
What three parameters does Fn:FindInMap take?
MapName, Top Level Key, Second Level Key:
Fn::FindInMap[MapName, TopLevel, SecondLevel]
I have a CloudFormation template Mapping set up to select an AMI for us-east-1, ap-southeast-2 and eu-west-1. My template is currently running out of ap-southeast-2. How would I construct the Fn:FindInMap call to use my current region? The mapping is called “AMIRegionMap” with nodes for the Region and the AMI Name is “AMIName”
You would use a pseudo parameter in the call: !Fn::FindInMap[ AMIRegionMap, !Ref "AWS::Region", AMIName]