Skip to main content
This lesson shows how to update a nested AWS CloudFormation stack by modifying the nested templates (EC2 and S3), uploading them to the same S3 location the parent stack references, and then updating the parent stack so CloudFormation re-evaluates the nested TemplateURLs and applies the changes. Goal
  • Change EC2 instance type from t3.micro to t3.small.
  • Add a Developer: John tag to the S3 bucket created by the nested S3 stack.
Why this matters
  • Updating an instance type may stop or replace the instance (possible downtime).
  • Updating nested templates requires the parent stack to reference the same S3 object keys (TemplateURL) so CloudFormation picks up the changes.
Resources changed (summary)
Resource TypeChangeTemplate file
EC2 InstanceInstanceType: t3.microt3.smallsimple-ec2.yaml
S3 BucketAdd tag Developer: Johnsimple-s3.yaml
Parent stackRe-run update so nested TemplateURLs are re-readParent template (no change required unless you change filenames)
Files to edit
  • simple-ec2.yaml (nested EC2 stack)
  • simple-s3.yaml (nested S3 stack)
Edit the nested templates locally, then upload them to the templates bucket the parent stack expects. Do not change the object key (filename) unless you also update the TemplateURL in the parent template. EC2 nested template — initial (before change)
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t3.micro
      ImageId: ami-0eb9d6fc9fab44d24
EC2 nested template — updated (after change)
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t3.small
      ImageId: ami-0eb9d6fc9fab44d24
Updating the InstanceType of an AWS::EC2::Instance can cause the instance to be stopped or replaced, which may result in downtime or a new instance ID. Plan for possible interruption when applying this change via CloudFormation.
S3 nested template — initial (before change)
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
S3 nested template — updated (after change)
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      Tags:
        - Key: Developer
          Value: John
Upload updated templates
  1. Save the modified templates locally.
  2. Upload simple-ec2.yaml and simple-s3.yaml to the S3 bucket your parent stack expects (same object keys).
    • If you change the filename/object key, you must update the parent template’s TemplateURL to the new S3 URL.
  3. Confirm the object details after upload (ETag, size, last modified, S3 URI) to ensure the correct files were replaced.
A screenshot of the AWS S3 console showing object details for "simple-ec2.yaml" in the bucket eden-kodekloud-lkjo-bkt-templates, including S3 URI, ARN, ETag, object URL, last modified date, size (140 B) and region (US East Ohio us-east-2). The left pane shows owner and file metadata while the right pane lists the resource identifiers and links.
Update the parent CloudFormation stack
  • In the CloudFormation console select the parent (Demo) stack.
  • Choose Update stack → Use current template (unless you intentionally changed the parent template).
  • Follow the wizard and acknowledge any required capabilities (for example, IAM or CAPABILITY_AUTO_EXPAND) before you submit the update.
A screenshot of the AWS CloudFormation console showing an "Update stack" notice that the template requires IAM resources and the CAPABILITY_AUTO_EXPAND capability. Two acknowledgement checkboxes are checked and navigation buttons ("Previous", "Next", "Cancel") are visible.
Parent template — nested stack references (ensure TemplateURL points to uploaded objects)
Resources:
  S3Stack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://eden-kodekloud-lkjo-bkt-templates.s3.us-east-2.amazonaws.com/simple-s3.yaml

  EC2Stack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://eden-kodekloud-lkjo-bkt-templates.s3.us-east-2.amazonaws.com/simple-ec2.yaml
Submit the update
  • When you submit the parent stack update, CloudFormation creates a change set and identifies which nested stacks have changes.
  • Execute the change set. CloudFormation updates the parent stack and then updates each nested stack according to its TemplateURL contents.
Confirm update completion
  • After execution, the parent and nested stacks should reach UPDATE_COMPLETE status in the Stacks list.
A screenshot of the AWS CloudFormation "Stacks" page showing three stacks (DemoStack and two nested stacks) all marked "UPDATE_COMPLETE" with creation timestamps of 2025-07-14. The top toolbar shows action buttons like Delete, Update stack, Stack actions, and Create stack.
Verify the changes
  1. Verify S3 bucket tags (the bucket you created via the nested stack, not the templates bucket)
  • Open the S3 console, refresh and open your deployed bucket.
  • Go to Properties → Tags and confirm there is a Developer tag with value John.
A screenshot of the AWS S3 console showing the "General purpose buckets" page with two buckets listed and a prominent "Create bucket" button. The buckets shown include names like "y0wahbcpenen" and "eden-kodekloud-lkjo-bkt-templates" in the US East (Ohio) us-east-2 region.
A screenshot of the AWS S3 console showing the "Tags" section for a bucket, listing four tags including aws:cloudformation:stack-name, aws:cloudformation:logical-id, aws:cloudformation:stack-id and a "Developer" tag with value "John." The page also shows the bucket navigation and an Edit button for tags.
  1. Verify EC2 instance type
  • Open the EC2 console, refresh Instances, and locate the instance created/managed by the nested EC2 stack.
  • Confirm the Instance Type column shows t3.small.
Completion
  • If both verifications pass (S3 tag and EC2 instance type), the nested stack update succeeded and the desired resource changes are in effect.
Always keep the parent template’s TemplateURL values aligned with the S3 object keys used for nested stacks. If you rename or move nested templates in S3, update the parent template to point to the new TemplateURL before applying the update.
Links and references

Watch Video