Skip to content

Cloudformation fails to detect changes when AWS::LanguageExtensions is used

0

My test case is a simple CloudFormation template using AWS::LanguageExtensions. Note that Transform is not used in the template and if I comment the Transform, template will work as expected. Below is a simplified version to show the bug. I noted this in larger template I was working on and reduced the case to one below.

---
AWSTemplateFormatVersion: '2010-09-09'
Description: Changes not detected when parameter is updated
Transform: 'AWS::LanguageExtensions'

Parameters:

  Hibernate:
    Type: String
    Description: "When true, IGW is not deployed"
    Default: false
    AllowedValues: [true, false]

Conditions:
  Deploy: !Equals [!Ref Hibernate, false]

Resources:

  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: '10.0.0.0/22'
      Tags:
        - Key: Name
          Value: !Sub '${AWS::StackName}'

  IGW:
    Type: AWS::EC2::InternetGateway
    Condition: Deploy
    Properties:
      Tags:
      - Key: Name
        Value: !Sub '${AWS::StackName} IGW'

  InetGWattachment:
    Type: AWS::EC2::VPCGatewayAttachment
    Condition: Deploy
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref IGW

If I deploy this and then try to update the stack by changing Hibernate parameter value, I get the following error

cfn console error

If I change Hibernate parameter but also replace the current template with the same version, then changes are recognized and conditional resources are deployd/removed as expected.

Am I missing something, is this known bug (with work-a-round?) or something else?

EXPERT
asked 2 months ago41 views
1 Answer
0
Accepted Answer

This is a known behavior when using the AWS::LanguageExtensions transform. When updating a CloudFormation stack that uses this transform, you cannot use the "Use existing template" option. You must explicitly provide the template file again, even if the template itself hasn't changed.

This is a documented consideration for the AWS::LanguageExtensions transform. When you only change parameter values without re-submitting the template, CloudFormation doesn't properly detect the changes that should occur based on those parameter updates when the transform is present.

The workaround you've already discovered is the correct approach: when updating the stack, always select the option to upload or specify your template file again, rather than using the existing template. This ensures CloudFormation properly processes the parameter changes through the transform and generates the correct change set.

This behavior is specific to stacks using the AWS::LanguageExtensions transform and is not a bug in your template structure. Your template is correctly formatted, and the issue you're experiencing is an expected limitation of how the transform interacts with stack updates when only parameters are changed.
Sources
AWS::LanguageExtensions transform - AWS CloudFormation

answered 2 months ago
EXPERT
reviewed 2 months ago
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.