Mazzy
Mazzy

Reputation: 14189

Validation Error: no updates are to be performed in Cloudformation returns error

When I execute in my CI aws-cli to update CloudFormation stack, I get the following error message:

An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed.

No updates are seen like error hence the CI fails. Any idea how to capture this error?

Upvotes: 15

Views: 13362

Answers (3)

Sean Xia
Sean Xia

Reputation: 11

For solution #5, we need to put output=$(aws cloudformation update-stack --stack-name foo 2>&1) in if statement, otherwise the statement will return a non-zero code, and shell will exit

My enhanced version:

#!/bin/bash

if output=$(aws cloudformation update-stack --stack-name foo 2>&1)
then
  echo "$output"
else
  RESULT=$?
  echo $output
  if [[ "$output" == *"No updates are to be performed"* ]]; then
    echo "No cloudformation updates are to be performed."
    exit 0
  else
    exit $RESULT
  fi
fi

Upvotes: 0

Zoran Majstorovic
Zoran Majstorovic

Reputation: 1609

Unfortunately, command aws cloudformation update-stack does not have an option: --no-fail-on-empty-changeset

but, perhaps, something like this could work:

#!/bin/bash

output=$(aws cloudformation update-stack --stack-name foo 2>&1)

RESULT=$?

if [ $RESULT -eq 0 ]; then
  echo "$output"
else
  if [[ "$output" == *"No updates are to be performed"* ]]; then
    echo "No cloudformation updates are to be performed."
    exit 0
  else
    echo "$output"
    exit $RESULT
  fi
fi

Upvotes: 6

Kiran N
Kiran N

Reputation: 197

use --no-fail-on-empty-changeset along with your aws cli command.

eg: aws cloudformation deploy --template-file ${TEMPLATE_FILE_PATH} --stack-name ${CF_STACK_NAME} --parameter-overrides ${PARAMETER_OVERRIDES} --no-fail-on-empty-changeset

Upvotes: 7

Related Questions