CloudFormation Flashcards
What is the Infrastructure as Code in AWS?
IaC
AWS CloudFormation
What does infrastructure as code mean?
Managing and provisioning data centers through machine readable definition files
Does CloudFormation cost anything to use?
No, The services it provisions does cost money.
Which 2 formats are supported for creating CloudFormation templates?
JSON
YAML
The section of a Cloudformation template that contains the AWS components being created
Resources
What is the minimum number of resources you can define in a CloudFormation template?
1
CloudFormation Templates requires you to at least list one resource.
Values that should be returned after deploying a CloudFormation template should be defined in what section?
Outputs
Values that returned eg. an ip-address of new server created.
Values that should be returned after deploying a CloudFormation template should be defined in what section?
Outputs
Values that returned eg. an ip-address of new server created.
A collection of CloudFormation templates ready to launch on AWS
AWS QuickStart
Who creates and provides AWS Quickstarts?
AWS solutions architects and 3rd party partners
The 3 types of Cloud Formation stack updates
Update with no interruption
Update with some interruption
Replacement
The 3 types of Cloud Formation stack updates
Update with no interruption (Without change resource’s physical ID)
Update with some interruption (Retain resource’s physical ID)
Replacement (It changes the resource’s physical ID)
What are 2 reasons that you might want to prevent stack updates?
Prevent data loss
Prevent interruption to service
What are 2 benefits of using NestedStacks?
Reduces complexity of larger templates
Makes templates more re-usable
When using NestedStacks where must you store the nested template files?
S3 Bucket
It’s a .template
This CloudFormation feature allows you to reference other templates inside your own template
Nested Stacks
ˈnɛstəd stæks
When creating a stack via the CLI which option would you provide to disable the automatic rollback feature?
–ignore-rollback
When you ___, ___ or ___, a stack, you can encounter and error and CloudFormation will attempt to rollback your stack to its previous state.
Eg.
Template Syntax Error
Try deleting a Resource which No longer exists
Create
Destroy
Update
In CloudFormation “Drift” is considered when this occurs
The current stacks configuration differs from what CloudFormation expects it to be
When detecting drift with NestedStacks where do you need to run the drift detection?
On each nested stack
What are common causes of drift in CloudFormation?
Two common causes
Deleting resources
Developers modifying resources directly
In Cloud Formation, What is when your stack’s actual configuration differs by what CloudFormation Expects.
Drift
It Has drifted
In CloudFormation you can use Pseudo Parameters, if you want to have the value “us-east-1” in your Template, what do you have to write?
!REF “ASW::Region”
Resource Attributes In CloudFormation allows you to add policies, what are some policies you can set?
There are 5
- CreationPolicy (Success signals)
- DeletionPolicy (If you delete an RDS, delete, retain, snapshot)
- UpdatePolicy (ASG, ECache, Lambda Alias)
- UpdateReplacePolicy (If you update an RDS, delete, retain…)
- DependsOn (Resources that depends on others)
CreationPolicy
Use this attribute when you want to wait on resource configuration actions before stack creation proceeds. For example, if you install and configure software applications on an EC2 instance, you might want those applications to be running before proceeding. In such cases, you can add a CreationPolicy attribute to the instance, and then send a success signal to the instance after the applications are installed and configured
DeletionPolicy
With this attribute you can preserve or (in some cases) backup a resource when its stack is deleted. You specify a DeletionPolicy attribute for each resource that you want to control. If a resource has no DeletionPolicy attribute, AWS CloudFormation deletes the resource by default.
UpdatePolicy
Use the UpdatePolicy attribute to specify how AWS CloudFormation handles updates to the
UpdateReplacePolicy
Use the UpdateReplacePolicy attribute to retain or (in some cases) backup the existing physical instance of a resource when it is replaced during a stack update operation.
DependsOn
With this attribute you can specify that the creation of a specific resource follows another. When you add a DependsOn attribute to a resource, that resource is created only after the creation of the resource specified in the DependsOn attribute.
This CloudFormation feature lets you assign values to properties that are not available until runtime
Intrinsic Functions
AWS CloudFormation provides several built-in functions that help you manage your stacks. Use intrinsic functions in your templates to assign values to properties that are not available until runtime.
In CloudFormation Fn:GetAtt and Fn:Sub are common examples of these
And also: Fn::Base64 Fn::Cidr Condition functions Fn::FindInMap Fn::GetAtt Fn::GetAZs Fn::ImportValue Fn::Join Fn::Select Fn::Split Fn::Sub Fn::Transform Ref
Intrinsic Functions
AWS CloudFormation provides several built-in functions that help you manage your stacks. Use intrinsic functions in your templates to assign values to properties that are not available until runtime.
You can use intrinsic functions only in specific parts of a template. Currently, you can use intrinsic functions in resource properties, outputs, metadata attributes, and update policy attributes. You can also use intrinsic functions to conditionally create stack resources.
This common Cloud Formation intrinsic function lets you select various attributes from a specific AWS resource
Fn:GetAtt
{ “Fn::GetAtt” : [ “logicalNameOfResource”, “attributeName” ] }
What is CDK
Cloud Development Kit
Its an open source software development framework to define your cloud application resources using familiar programming languages.
Imperative Infrastructure
- More Flexible
- Less certain
- Write Less
You can write IaC using your favorite language with this
CDK
Cloud Development Kit
Imperative Infrastructure
- More Flexible
- Less certain
- Write Less
In CloudFormation, Stack Updates can be performed two different ways
- Direct Update (Submit and it deploys)
- Executing changes set (Preview and decide if deploy)
What are the 8 sections you cand find in a CloudFormation template?
- Metadata (Additional information)
- Description (What this template is supposed to do)
- Parameters (Values to pass at runtime)
- Mapping (Key-values to use in the template)
- Conditions (It’s true it creates the resource or output)
- Transform (Macros, SAM)
- Resources (EC2, Lambda, RDS, Lambda)
- Outputs (Values returned)
What is CloudFormation?
What are its 9 components?
- CloudFormation is the Infrastructure as Code (IaC) powered by AWS and it automates the provisioning of resources
- NestedStacks (Break up the template)
- Template Sections (Metadata, description, parameters..)
- Stack Updates (Direct updates, Change sets)
- Update circumstances (With no interruption…)
- Intrinsic functions (Ref for pseudo…, Fn:…)
- Pseudo parameters (!Ref “AWS::Region”…)
- Drift detection (Differences)
- Resource attributes (Creation policy, Deletion policy…)
- SAM
In CloudFormation CLI
The command uploads local artifacts, such as source code for an AWS Lambda function or a Swagger file for an AWS API Gateway REST API, to an S3 bucket.
aws cloudformation package –template-file /path_to_template/template.json –s3-bucket bucket-name –output-template-file packaged-template.json