Exam Points Flashcards
Exam prep
How does CloudFormation promote Separation of Concern
Stacks
You can create stacks for many apps and layers,
e.g.
* VPC Stacks
* Network stacks
* App Stacks
What is a CloudFormation Template
It’s a JSON or YAML file that declares your requirement
A template has to be uploaded in S3 then referenced in CloudFormation
It must be versioned. Immutable.
Metadata
A template can utilise References and Functions
How does CloudFormation represent the AWS Components it wants to create?
By using a Resource
looks like this AWS::aws-product-name::data-type-name
When should you use a CloudFormation parameter
If the resource config is likely to change in the future then paramaterise it. That way you won’t have to re-upload a template if content changes.
What are Valid Parameter Settings (CloudFormation)
Type:
- String
- Number
- CommaDelimitedList
- List <Type>
- AWS Parameter
Description
Constraints
ConstraintDescription (String)
Min/MaxLength
Min/MaxValue
Default
AllowedValues (array)
AllowedPattern (regexp)
NoEcho (Boolean)</Type>
How to reference a CloudFormation parameter
Fn:: Ref
in YAML it is !Ref
can reference other params in the template
What are CloudFormation PseudoParameters
AWS::AccountId
AWS::NotifiationARNs
AWS::NoValue
AWS::Region
AWS::StackId
AWS:StackName
What are CloudFormation Mappings?
They are fixed variables within your CloudFormaton Template, values are hardcoded
eg
RegionMap:
us-east-1:
“32”: “ami-123”
us-west-1:
“32”: “ami-456”
When to use Mappings V Parameters in CloudFormation
When you know upfront all the values that you will need and they can be deduced from variables like ‘region’.
Use parameters when the values are user-specific and may change at run time.
How do you access Mapping Values in CloudFormaton?
Fn::FindInMap
in YAML
!FindInMap [MapName, TopLevelKey, SecondLevelKey]
How do you do CloudFormation Outputs?
These are optional and are declared in a YAML using Export:
Outputs:
StackSSHSecurityGroup:
Description: this is the description
Value: !Ref MySecurityGroup
Export:
Name: SSHSecurityGroup
We then reference it using:
!ImportValue SSHSecurityGroup
For each AWS account, export names must be unique within a region
What are conditions in CloudFormation
Control creation of resources based on a condition.
eg
Conditions:
CreateProdResources: !Equals [!Ref EnvType, prod]
And, Equals, If, Not, Or are all valid functions
What is Fn:: GetAtt in cloudformation used for?
It gets the attributes of resources you create.
So for example
!GetAtt EC2Instance.AvailabilityZone
How does Fn::Join work in CloudFormation
It joins values with a delimiter
e.g.
!Join [delimiter, [a, b, c]]
What happens if CloudFormation Stack Creation fails
Default: everything gets rolled back and you can look at the log
Option to disable rollback to troubleshoot
What happens if CloudFormation Stack update fails
The stack automatically rolls back to last known working state, logs can show errors
Pattern for CF Stackevent notifications
Enable SNS integration on Stack Events, you can have a Lambda filtering on ROLLBACK IN PROGRESS events, that trigger another SNS notification to say send an email.
What is a ChangeSet in CloudFormation
Similar to a plan in terraform, it will show you the diff
Why would you use Nested Stacks (CloudFormation)
Considered best practice for configurations that are reused e.g a Security Group
To update a nested Stack, always update the parent (root stack)
Why would you use Cross Stacks (CloudFormation)
When stacks have different lifecycles
When you need to pass export values to many stacks e.g. VPC id
use outputs export and Fn::ImportValue
Why would you use a StackSet (CloudFormation)
To create update or delete stacks across multiple accounts and regions
Admin account creates stack sets
Trusted Accounts to create, update, delete, etc stack instances
When you update a stack set, ALL associated stack instances are updated across accounts and regions
How to protect against manual config changes (CloudFormation)
CloudFormation Drift
What is a Stack Policy (CloudFormation)
It’s a Json document that defines the update actions that are allowed on specific resources
it protects resources from unintentional updates
Specify an explicit ALLOW for the resources you want to be updated.
What tool automates Software package deployment to AWS as part of continuous integration and delivery
AWS Code Deploy
fully managed “deployment” service that automates software deployments to a variety of compute services such as Amazon EC2, AWS Fargate, AWS Lambda, and your on-premises servers.