Course menuSOA-C03

Exams / SOA-C03 / Study guide / CloudFormation and the AWS CDK

CloudFormation and the AWS CDK: SOA-C03 study notes and practice questions

What to know about CloudFormation and the AWS CDK for the SOA-C03 exam, from the Deployment, Provisioning, and Automation domain (22% of the exam guide), then 3 free questions to test it. Part of the SOA-C03 study guide.

Last verified against current AWS documentation ·How we write our questions

What to know for the exam

CloudFormation questions ask how to change infrastructure safely and predictably.

Core ideas

  • A template (YAML or JSON) defines resources; a stack is one deployed copy.
  • Parameters make templates reusable; mappings look up values (such as per-Region settings); conditions create resources only in some cases; outputs expose values, and exports with Fn::ImportValue share them between stacks.
  • Nested stacks reuse common components; StackSets deploy across accounts and Regions.
  • Dynamic references pull values from Parameter Store or Secrets Manager at deploy time, so secrets aren’t in templates.

Safe changes

Feature Does
Change sets Preview what an update will add, modify or replace before running it
Stack policy Stops updates to specific resources (such as a production database) unless overridden
DeletionPolicy Retain or Snapshot keeps data when the resource or stack is deleted
UpdateReplacePolicy Keeps or snapshots the old resource when an update replaces it
Termination protection Stops the whole stack being deleted
Drift detection Finds resources changed outside CloudFormation
Rollback triggers Roll back an update if a CloudWatch alarm fires during it

Waiting for software

By default a resource is complete when the service says it’s running. A CreationPolicy (or WaitCondition) makes the stack wait for cfn-signal from the instance, sent after its software is installed. Use cfn-init to install packages and files from metadata.

AWS CDK

Write infrastructure in TypeScript, Python, Java and other languages; cdk synth produces CloudFormation and cdk deploy deploys it. cdk diff previews changes. The first deploy in an account and Region needs cdk bootstrap.

Common traps

  • Updating a property that requires replacement without a change set or DeletionPolicy, and losing data.
  • Stack shows CREATE_COMPLETE but the app isn’t ready. Add a creation policy and signals.
  • Manual changes cause drift and failed updates later.

Try the 3 practice questions

A public library manages its catalog database, an Amazon RDS DB instance, with AWS CloudFormation.

A developer has updated the template to change the DB instance identifier and the storage type.

Before anything is applied to production, the operations team wants to see exactly which resources CloudFormation will modify and whether any will be replaced.

What should a CloudOps engineer do?

Choose one answer.

  1. A. Run drift detection on the stack and review which resources CloudFormation reports as modified.
  2. B. Create a change set from the new template and check the Replacement value for each change.
  3. C. Validate the new template with the ValidateTemplate API and review the list of resources it returns.
  4. D. Apply a stack policy that denies all updates, run the update, and read the errors for each blocked resource.
Show the answer and explanation

Answer: B

Explanation

Change sets let you preview a stack update. CloudFormation compares the proposed template with the current stack and lists each change, including whether a resource will be replaced, as happens when a DB instance identifier changes. Nothing is applied until the change set is executed.

Study

A ski resort's CloudFormation stack launches an EC2 instance whose user data installs and configures the ticketing application, which takes about eight minutes.

The stack reports CREATE_COMPLETE about two minutes after launch, before the application is ready, and when the install script fails the stack still reports success.

The team wants the stack to complete only after the application is installed, and to roll back if the install fails or takes over 15 minutes.

What should a CloudOps engineer do?

Choose one answer.

  1. A. Add a DependsOn attribute to the instance that names the application's security group and IAM instance profile.
  2. B. Add a CreationPolicy with a 15-minute resource signal timeout to the instance, and run cfn-signal with the install script's exit status at the end of user data.
  3. C. Add an UpdatePolicy attribute with a 15-minute pause time to the instance so that CloudFormation waits before marking it complete.
  4. D. Add a CloudWatch alarm on the instance's status checks to the template and set the stack's rollback trigger to that alarm.
Show the answer and explanation

Answer: B

Explanation

By default CloudFormation marks an instance complete when EC2 reports it running, which says nothing about the software inside. A CreationPolicy makes CloudFormation wait for signals, and cfn-signal sends success or failure from user data. If no success signal arrives before the timeout, the resource fails and the stack rolls back.

Study

Question 3

Harder · choose 2 ·Link to this question (question 3)

A pet insurer manages a claims project's Amazon RDS for MySQL DB instance in a CloudFormation stack.

Two rules apply. First, the stack will be deleted when the project ends in two years, and a final copy of the database must remain afterward.

Second, until then, no stack update may replace or delete the DB instance by accident, while other resources in the stack must stay updatable.

Which TWO actions meet these requirements? (Choose two.)

Choose two answers.

  1. A. Run drift detection on the stack every day and alert the team if the DB instance's configuration has changed.
  2. B. Apply a stack policy that denies Update:Replace and Update:Delete on the DB instance and allows all updates on other resources.
  3. C. Set UpdateReplacePolicy: Retain on the DB instance so that updates are not allowed to replace it during the project.
  4. D. Set DeletionPolicy: Snapshot on the DB instance resource so that CloudFormation takes a final snapshot when the stack is deleted.
  5. E. Turn on termination protection for the stack so that the database cannot be deleted while the project is running.
Show the answer and explanation

Answers: B, D

Explanation

Two different CloudFormation controls cover the two rules. DeletionPolicy decides what happens to a resource when the stack is deleted, and Snapshot keeps a final copy of the database. A stack policy limits what stack updates may do to specific resources. Termination protection, UpdateReplacePolicy and drift detection solve related but different problems.

Study

Want more on CloudFormation and the AWS CDK? The 5 full-length practice sets have 13 more CloudFormation and the AWS CDK questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets

Study CloudFormation and the AWS CDK

More Deployment, Provisioning, and Automation topics