AWS CloudFormation interview questions and answers for cloud engineers

CloudFormation interview questions check that you can write a template, predict what an update will do to live resources, and recover when a stack gets stuck. Expect template sections, Ref, GetAtt and Sub, parameters and conditions, change sets and replacement, deletion policies, drift, nested stacks versus exports, StackSets and custom resources. Senior candidates are also asked how CloudFormation compares with Terraform and the CDK, and how they would keep hundreds of stacks safe.

By Published 6 min read

Who is asked about CloudFormation

CloudFormation is AWS's own infrastructure as code service, and tools such as the CDK and SAM produce CloudFormation templates under the hood. That makes it a regular topic in AWS-heavy DevOps, cloud engineer and platform interviews, even at companies that write most of their infrastructure in another tool. Broader AWS questions about networking and services live on AWS interview questions, and the multi-cloud alternative is on Terraform interview questions.

A typical round starts with template basics, then shows a template or a change set and asks what will happen when it is applied. Senior rounds bring stuck stacks, accidental replacements of databases and how to roll out a baseline to every account in an organization.

CloudFormation fundamentals questions

Template and stack basics
QuestionWhat it testsWhat a strong answer shows
What is a stack and what is a template?Core modelA template is a JSON or YAML file describing resources. A stack is the set of real resources CloudFormation created from that template, managed and updated as one unit.
Which template sections do you know, and which one is required?AnatomyParameters, Mappings, Conditions, Rules, Transform, Resources and Outputs, plus metadata and a description. Only Resources is required.
Ref versus GetAtt?IntrinsicsRef returns a resource's default identifier, which differs by type: a bucket's name, a queue's URL. GetAtt returns a named attribute such as an ARN. The resource documentation lists both.
What does Fn::Sub do?StringsIt substitutes variables into a string, including pseudo parameters and resource references, for example a name built from the stack name and region. It is easier to read than long Join chains.
What are pseudo parameters?Built-insValues CloudFormation provides, such as AWS::Region, AWS::AccountId, AWS::StackName and AWS::Partition. AWS::NoValue removes a property when used inside a condition.
How do Conditions work?ConditionalsDefined with functions such as Equals, And and Not, then attached to a resource, output or property with Condition or Fn::If. They let one template serve several environments.
What are Mappings for?LookupsStatic lookup tables read with FindInMap, often keyed by region or environment. Less common now that parameters can read from Parameter Store.
How does CloudFormation order resource creation?DependenciesImplicitly from Ref and GetAtt, so referenced resources come first, and explicitly with DependsOn when there is a dependency the template cannot see.
How should secrets reach a template?SecretsThrough dynamic references to Secrets Manager or Parameter Store, resolved at deploy time, rather than parameters with default passwords. NoEcho hides a parameter's value in output but is not a vault.
What are Outputs and exports?Sharing valuesOutputs publish values from a stack. An export makes one importable by other stacks in the same account and region with ImportValue.
Template and stack basics. Scroll sideways on a small screen.

A template to read

AWSTemplateFormatVersion: "2010-09-09"
Description: Orders storage and queue for one environment
Parameters:
  Env:
    Type: String
    AllowedValues: [dev, prod]
  AlarmEmail:
    Type: String
    Default: ""
Conditions:
  IsProd: !Equals [!Ref Env, prod]
  HasAlarmEmail: !Not [!Equals [!Ref AlarmEmail, ""]]
Resources:
  OrdersBucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Properties:
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: aws:kms
      VersioningConfiguration:
        Status: Enabled
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: true
        IgnorePublicAcls: true
        RestrictPublicBuckets: true
  OrdersDeadLetterQueue:
    Type: AWS::SQS::Queue
  OrdersQueue:
    Type: AWS::SQS::Queue
    Properties:
      VisibilityTimeout: 180
      MessageRetentionPeriod: !If [IsProd, 1209600, 345600]
      RedrivePolicy:
        deadLetterTargetArn: !GetAtt OrdersDeadLetterQueue.Arn
        maxReceiveCount: 5
  AlarmTopic:
    Type: AWS::SNS::Topic
    Condition: HasAlarmEmail
    Properties:
      Subscription:
        - Protocol: email
          Endpoint: !Ref AlarmEmail
Outputs:
  OrdersQueueUrl:
    Value: !Ref OrdersQueue
    Export:
      Name: !Sub "${AWS::StackName}-OrdersQueueUrl"
  OrdersBucketName:
    Value: !Ref OrdersBucket
An encrypted bucket kept on delete and on replacement, a queue with a dead-letter queue, environment-specific retention and an optional alarm topic.
  • What does `Ref` return for the queue and for the bucket? The queue's URL and the bucket's name. The dead-letter target needs the ARN, hence GetAtt.
  • Why both DeletionPolicy and UpdateReplacePolicy on the bucket? The first keeps the bucket when the stack or resource is deleted; the second keeps the old one when an update forces a replacement.
  • Why has the bucket no fixed name? Custom names block replacement, because the new resource cannot take a name the old one still holds. Generated names avoid that and avoid collisions across environments.
  • What happens if AlarmEmail is empty? The condition is false, so the topic is not created at all, and nothing references it, which keeps the template valid.
  • What does the export commit you to? Another stack can import the queue URL, and from then on you cannot change or delete that export until every importer stops using it.

Updates, change sets and failure questions

Intermediate questions
QuestionWhat it testsWhat a strong answer shows
What is a change set and why use one?PreviewingA preview of what an update will add, modify or remove, created before executing. The key column is Replacement: True means the resource will be deleted and recreated, with a new physical ID.
Which changes cause replacement?Update behaviorIt depends on the property: each property is documented as no interruption, some interruption or replacement. Renaming a logical ID always replaces, because CloudFormation sees a delete and a create.
How do you protect a production database from accidental replacement?SafetyDeletionPolicy and UpdateReplacePolicy set to Retain or Snapshot, a stack policy that denies replace and delete on that resource, termination protection on the stack, and reviewing change sets in CI.
What happens when a stack update fails?RollbackCloudFormation rolls back to the last known good state. If the rollback itself fails, the stack sits in UPDATE_ROLLBACK_FAILED until you fix the cause and continue the rollback, skipping resources if you must.
Why might a stack fail to delete?DeletionA non-empty bucket, a resource still in use by something outside the stack, an export still imported elsewhere, or termination protection. Retained resources are left behind deliberately.
What is drift and how do you handle it?DriftDrift is a difference between the template and the live resource, usually from console changes. Drift detection reports it; the fix is to bring the change into the template or revert it, then stop console edits with permissions.
How do you bring an existing resource under CloudFormation?ImportA resource import operation with the resource added to the template, a DeletionPolicy set and its identifier supplied, done through a change set.
Nested stacks versus cross-stack exports?CompositionNested stacks are child stacks deployed and updated with their parent, good for reusable pieces within one lifecycle. Exports link independent stacks with separate lifecycles but create hard coupling.
What are the CAPABILITY flags?AcknowledgmentDeploying templates that create IAM resources, named IAM resources or that expand macros requires acknowledging capabilities, so a template cannot quietly create roles.
How do cfn-init, cfn-signal and CreationPolicy fit together?Instance bootstrapcfn-init applies configuration from template metadata on an instance, cfn-signal reports success, and a CreationPolicy makes the stack wait for that signal instead of marking the instance done when it boots.
Intermediate questions. Scroll sideways on a small screen.
aws cloudformation deploy \
  --stack-name orders-prod \
  --template-file orders.yaml \
  --parameter-overrides Env=prod \
  --no-execute-changeset

aws cloudformation describe-change-set \
  --stack-name orders-prod \
  --change-set-name <name-printed-above> \
  --query "Changes[].ResourceChange.[Action,LogicalResourceId,Replacement]"
Previewing an update before applying it. The stack and file names are placeholders.

Senior and scenario questions

Organization-scale and design questions
Scenario or questionWhat it testsWhat a strong answer shows
Roll out a logging and security baseline to every account.StackSetsA StackSet with service-managed permissions targeting organizational units, automatic deployment to new accounts, and failure tolerance and concurrency settings so a bad version stops early.
A Lambda-backed custom resource left the stack hanging.Custom resourcesThe function never sent a response to the pre-signed URL, often because it threw before responding or did not handle Delete. Always respond, including on errors and deletes, and set a sensible timeout.
A developer renamed a logical ID and the database was recreated.Incident reviewRenames mean replacement. Restore from the snapshot or retained copy, then add change set review with a check that fails on Replacement for stateful resources, and policies that retain data.
CloudFormation or Terraform?Tool choiceCloudFormation is AWS-managed with no state file to run, deep AWS integration and StackSets. Terraform covers many providers, has a larger module ecosystem and a plan workflow teams like. Existing skills and multi-cloud needs usually decide.
CDK or raw templates?AbstractionThe CDK uses a programming language and synthesizes templates, which helps with loops and shared constructs. The trade-off is another layer to debug: reviewers should still read the synthesized template or its diff.
How would you test templates in CI?Quality gatesLint for schema errors, policy-as-code rules for things such as public buckets or unencrypted volumes, change sets against a real account for review, and deployment to a test account before production.
A stack is stuck in UPDATE_ROLLBACK_FAILED on a Friday evening.RecoveryRead the events for the resource that failed to roll back, fix the external cause if possible, then continue the update rollback, skipping only resources you understand, and record what is now out of sync.
How do you split a large monolithic stack?RefactoringMove resources out by retaining them, removing them from the old stack and importing them into the new one, one group at a time, with exports replaced by parameters where coupling hurts.
Organization-scale and design questions. Scroll sideways on a small screen.

Fictional example

Answering "How do you make CloudFormation deploys safe for stateful resources?"
Interviewer
We lost a production table last year because an update replaced it. What would you put in place?
Candidate
I would work in layers. In the templates, every stateful resource such as a table, a bucket or a database gets DeletionPolicy and UpdateReplacePolicy set to Retain or Snapshot, and avoids custom physical names unless there is a strong reason. On the stack, a stack policy denies Update:Replace and Update:Delete on those logical IDs, and termination protection is on. In the pipeline, every deploy creates a change set first, and a small script fails the build if any change on a stateful resource type shows Replacement as True or Conditional, so a human has to look. Finally I would make sure backups exist independently of CloudFormation, because the goal is to recover even if every one of those checks is bypassed.

A one-week CloudFormation practice plan

  • Day 1: write a template with a bucket, a queue and outputs. Deploy it, read the events tab and look up what Ref returns for each type.
  • Day 2: add parameters, a condition and a mapping, and deploy it twice for two environments.
  • Day 3: create change sets for a harmless property change and for a change that forces replacement. Compare the Replacement column.
  • Day 4: break an update on purpose to trigger a rollback, change a resource in the console and run drift detection.
  • Day 5: split the template into a nested stack, add an export and try to delete the exporting stack to see the error.
  • Days 6 and 7: answer the scenario table out loud and practice the CloudFormation versus Terraform answer without picking a side by reflex.

Templates usually deploy something you will also be asked about. See AWS Lambda interview questions for the functions many stacks define, Helm interview questions if the workloads run on Kubernetes, and DevOps engineer interview questions for the full loop.

Change set questions test whether you think about what an update destroys before you run it, and that habit is easier to show than to claim. Natively, an AI interview assistant for Mac and Windows, transcribes your practice interviews on your computer so you can review whether you raised replacement and rollback without prompting. While practicing it can read a template or a stack event error from a screenshot and suggest a cause, and with Pro or the free trial it can use your résumé and the job description. Every transcript and note is kept so you can review it afterwards.

Questions people ask

What CloudFormation questions are asked in AWS interviews?

Template sections, Ref versus GetAtt, Sub and pseudo parameters, conditions, change sets and replacement, DeletionPolicy, rollback states, drift detection, nested stacks versus exports, StackSets, custom resources and CloudFormation versus Terraform.

What is a change set in CloudFormation?

A preview of the changes an update will make to a stack before you run it. It lists each resource to add, modify or remove and whether a modification will replace the resource.

What is the difference between Ref and GetAtt?

Ref returns a resource's default identifier, which depends on the type, such as a bucket name or a queue URL. GetAtt returns a specific attribute, such as an ARN.

How do I prepare for a CloudFormation interview?

Deploy a small template, create change sets for an in-place change and a replacement, trigger a rollback, detect drift after a console edit, and practice explaining how you would protect stateful resources.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP