验证错误:在 Cloudformation 中不执行更新返回错误

Maz*_*zzy 8 amazon-web-services aws-cli

当我在 CI aws-cli 中执行更新 CloudFormation 堆栈时,收到以下错误消息:

An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed.
Run Code Online (Sandbox Code Playgroud)

没有更新被视为错误,因此 CI 失败。知道如何捕获此错误吗?

小智 7

使用--no-fail-on-empty-changeset连同您的AWS CLI命令。

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


Zor*_*vic 5

不幸的是,命令aws cloudformation update-stack没有选项: --no-fail-on-empty-changeset

但是,也许,这样的事情可以工作:

#!/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
Run Code Online (Sandbox Code Playgroud)