DevOps Engineering on AWS Certification Infrastructure as Code with CloudFormation and CDK 2 — Questions and Answers
Question 1: What is the purpose of CloudFormation StackSets?
- To create nested stacks within a parent stack
- To deploy CloudFormation stacks across multiple accounts and regions simultaneously (Correct answer)
- To enforce stack deployment policies
- To version control CloudFormation templates
Correct answer: To deploy CloudFormation stacks across multiple accounts and regions simultaneously
CloudFormation StackSets extend CloudFormation to deploy stacks across multiple AWS accounts and regions in a single operation.
Question 2: Which CloudFormation template section is used to define conditions that control whether resources are created?
- Parameters
- Mappings
- Conditions (Correct answer)
- Rules
Correct answer: Conditions
The Conditions section defines logical conditions that can control whether specific resources are created or properties are assigned.
Question 3: In AWS CDK, what must be done before deploying CDK apps to a new account or region for the first time?
- Run cdk synth
- Run cdk bootstrap (Correct answer)
- Run cdk init
- Run cdk doctor
Correct answer: Run cdk bootstrap
Running cdk bootstrap provisions the necessary CDK toolkit resources (like an S3 bucket) in the target account and region before first deployment.
Question 4: A CloudFormation stack update fails midway. What happens to the stack by default?
- The stack remains in the partially updated state
- CloudFormation automatically rolls back to the previous stable state (Correct answer)
- CloudFormation deletes the stack
- CloudFormation pauses and waits for manual intervention
Correct answer: CloudFormation automatically rolls back to the previous stable state
By default, CloudFormation rolls back all changes to the previous stable state when a stack update fails.
Question 5: Which CloudFormation function substitutes variables in a string with values from parameters, resources, or pseudo-parameters?
- Fn::Join
- Fn::Select
- Fn::Sub (Correct answer)
- Fn::Split
Correct answer: Fn::Sub
Fn::Sub substitutes variables in an input string, replacing ${VariableName} placeholders with parameter values, resource attributes, or pseudo-parameters.
Question 6: What is a CloudFormation Change Set used for?
- Tracking resource costs before deploying
- Previewing how proposed changes will affect running resources before executing them (Correct answer)
- Rolling back failed deployments
- Enforcing resource tag policies
Correct answer: Previewing how proposed changes will affect running resources before executing them
A Change Set shows you a preview of how CloudFormation will modify your stack resources before you execute the changes.
What is the purpose of CloudFormation StackSets?