aws cloudformation deploy doesn't recognize change in default value

2

When we deploy a new version of a template, the difference in the new "default parameter" is not recognized by aws cloudformation deploy. Example:

cat <<EOF > cfn.yaml 
---
AWSTemplateFormatVersion: "2010-09-09"
Description: an example

Parameters:
  Param:
    Type: String
    Default: '1'

Resources:

  SsmParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /example
      Type: String
      Value: !Ref Param
EOF

Then use AWS CLI to deploy and check the result:

aws cloudformation deploy --template-file cfn.yaml --stack-name update-check
aws ssm get-parameter --name /example |  | jq '.Parameter.Value'

This gives "1" as a result

Now, change the CloudFormation template file:

cat <<EOF > cfn.yaml 
---
AWSTemplateFormatVersion: "2010-09-09"
Description: an example

Parameters:
  Param:
    Type: String
    Default: **'2'**

Resources:

  SsmParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /example
      Type: String
      Value: !Ref Param
EOF

Try to re-deploy this template:

aws cloudformation deploy --template-file cfn.yaml --stack-name update-check

Output:


Waiting for changeset to be created..

No changes to deploy. Stack update-check is up to date

This seems a bug to us, can you fix this?

asked 2 years ago2102 views
2 Answers
1

Hi THere

Use update-stack

example

cat <<EOF > cfn.yaml 
---
AWSTemplateFormatVersion: "2010-09-09"
Description: an example

Parameters:
  Param:
    Type: String
    Default: '1'

Resources:

  SsmParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /example
      Type: String
      Value: !Ref Param
EOF
aws cloudformation deploy --template-file cfn.yaml --stack-name update-check
aws ssm get-parameter --name /example | jq '.Parameter.Value'
"1"

Now change the template

cat <<EOF > cfn.yaml 
---
AWSTemplateFormatVersion: "2010-09-09"
Description: an example

Parameters:
  Param:
    Type: String
    Default: '2'

Resources:

  SsmParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /example
      Type: String
      Value: !Ref Param
EOF

Update the stack

[cloudshell-user@ ~]$ aws cloudformation update-stack --template-body file://cfn.yaml --stack-name update-check

{
    "StackId": "arn:aws:cloudformation:us-east-1:#########:stack/update-check/52e8a4f0-303d-11ed-8d03-xxxxxxxxxx"
}

[cloudshell-user@ ~]$ aws ssm get-parameter --name /example | jq '.Parameter.Value'
"2"
profile pictureAWS
EXPERT
Matt-B
answered 2 years ago
  • Thank you for your quick response. We discussed this internally and from a language point of view this sounds reasonable. When we look at the documentation (aws cloudformation deploy help), we see:

    Deploys the specified AWS CloudFormation template by creating and then executing a change set. The command terminates after AWS CloudFormation executes the change set. If you want to view the change set before AWS CloudFormation executes it, use the --no-execute-changeset flag.
    
    To update a stack, specify the name of an existing stack. To create a new stack, specify a new stack name.
    
    See 'aws help' for descriptions of global parameters.
    

    (The line "To update a stack, specify the name of an existing stack" triggered us to call this a bug).

    We would highly appreciate it when AWS would fix this.

1

I also tried it, and indeed reproduced the same issue.

This may be similar to the following GitHub Issue. [1].

[1] SSM Dynamic Reference Change not detected - Issue #844 - aws-cloudformation/cloudformation-coverage-roadmap https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/844

The above Issue is open, so reporting this event may be considered for a fix.

profile picture
mn87
answered 2 years 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.

Guidelines for Answering Questions