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.
How does Elastic Beanstalk work? What are the steps?
- Create Application
- Upload Version
- Launch environment
- Manage environment
What is an ‘immutable’ deploy in Elastic Beanstalk
A new ASG is launched pointing to the new instances
This is the best deployment if you want full capacity of the application and minimal impact of failed deployment
If you want to deploy a container image to Lambda, what must the container image do?
It must implement the Lambda Runtime API
also AWS Lambda service does not support Lambda functions that use multi-architecture container image
Which Credentials are supported in IAM for CodeCommit?
Git
AWS Access Keys
IAM Username and Password
SSH Keys are NOT SUPPORTED
Elastic Beanstack Use case for deploy using Rolling with Additional Batch’policy
costs less than immutable as it has less instances
maintains availablity of application throughout
but
takes longer
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines per resource, you can define the application you want and model it using YAML.
What resource types does it support?
AWS::Serverless::Api
AWS::Serverless::Application
AWS::Serverless::Function
AWS::Serverless::HttpApi
AWS::Serverless::LayerVersion
AWS::Serverless::SimpleTable
AWS::Serverless::StateMachine
Elastic Beanstalk - what happens if instances fail during a deployment and are terminated
Elastic Beanstalk will replace them with instances running the application version from the most recent successful deployment
SQS what is the message limit in a queue
unlimited
How do you handle manual approvals in the deployment process
Create one CodePipeline for your entire flow and add a manual approval step - You can add an approval action to a stage in a CodePipeline pipeline at the point where you want the pipeline to stop so someone can manually approve or reject the action. Approval actions can’t be added to Source stages. Source stages can contain only source actions.
SQS what is the retention of messages?
Default: 4 days
Max: 14
message otherwise persisted until consumer deletes it
SQS what is the limit on message size
256KB
Can SQS messages be out of order?
Yes, best effort ordering
SQS consumer receives how many messages at a time?
up to 10
How does an SQS consumer delete the message
DeleteMessageApi
How would you use SQS to decouple a front end web app that has a back end that does video processing and inserts into an S3 bucket
You would put an SQS queue between front end and back end
What sort of encryption is available for SQS and SNS? name 3
Inflight using HTTPS API
At rest using KMS
Client side if required
How do you regulate access to the SQS or SNS API
IAM Policies
What are SQS/SNS AccessPolicies?
Useful for cross account access to SQS queues /SNS topics
Useful for allowing other services to write to an SQS queue/SNS topic
What is the default MessageVisibilityTimeout and what is it used for
30 seconds
It means that once a message is polled by a consumer, it can’t be polled by another for 30 seconds.
This prevents multiple consumers from handling the same message.
If a message is not processed in time, it will be processed twice.
A consumer could call ChangeMessageVisibility API to get more time
What is the throughput of FIFO Queue
300 msg/s without batching, 3000 msg/s with
Exactly once capability and messages are processed in order by the consumer
What is Redrive to Source in a SQS Dead Letter Queue
Ability to replay messages after you have fixed any errors
What is a Delay Queue
It delays a message from 0 secs - 15 mins so consumers don’t see it immediately
This can be overridden using DelaySeconds parameter
What is the purpose of ‘long polling’?
When a consumer polls and waits for a message to arrive if there are none in the queue.
This decreases the number of API calls made to SQS and it increases efficency as well as decreasing latency of the app
Wait time can be between 1 - 20 sec
LongPolling can be enabled at API using ReceiveMessageWaitTimeSeconds or when creating the queue.
SQS What if the message you want to send exceeds the size limit of 256KB?
Use SQS Extended Client (java library)
In this pattern the producer sends the large message to S3 and sends a small metadata message to SQS Queue
The consumer polls the Queue and uses the small metadata message to retrieve the large item from the S3 bucket.
Important SQS Apis for exam
CreateQueue (MessageRetentionPeriod), DeleteQueue
* PurgeQueue: delete all the messages in queue
* SendMessage (DelaySeconds), ReceiveMessage, DeleteMessage
* MaxNumberOfMessages: default 1, max 10 (for ReceiveMessage API)
* ReceiveMessageWaitTimeSeconds: Long Polling
* ChangeMessageVisibility: change the message timeout
* Batch APIs for SendMessage, DeleteMessage, ChangeMessageVisibility
helps decrease your costs
SNS what is the max subscriptions per topic
12500000
SNS Topic Limit?
100000
What is the FAN OUT pattern?
A queue can only have one consumer
A topic can have many subscribers
Fan out - you push once in SNS
You have queues that subscribe to the topic
- SQS allows for: data persistence, delayed processing and retries of work
- Ability to add more SQS subscribers over time
- Make sure your SQS queue access policy allows for SNS to write
- Cross-Region Delivery: works with SQS Queues in other regions
AN S£ object create event to /images/ can only have one S3 event rule.
How can you propagate this across many consumers?
Use FAN out
use the single event to publish to an SNS topic, have some SQS queues subscribe to the topic
SNS Message filtering - what is it
a Json policy to filter messages send to the subscriptions allows subscribers to filter what they are interested in.
Kinesis High level what does it make it easy to do?
Collect, process and analyze streaming data in real time
Ingest real time data such as app logs, metrics, website clickstreams, IOT telemetry