Azure DevOps AWS CloudFormation Create/Update 堆栈任务 - 失败 'stack does not exist'

Azure DevOps AWS CloudFormation Create/Update Stack task - fails 'stack does not exist'

我有一个配置为使用 AWS CloudFormation Create/Update Stack 任务的发布管道。该任务配置为使用如下更改集:

然而,由于某种原因,管道一直在失败。它失败是因为它测试堆栈的存在,发现它不存在,切换到 'create' 模式,但随后测试是否存在变更集,并且因为变更集也不存在而失败? ?这毫无意义。

2020-12-08T03:54:36.5413925Z Checking existence for stack S2CSalesOrderStack
2020-12-08T03:54:37.5245618Z Test for existence of stack S2CSalesOrderStack returned error: 'ValidationError: Stack with id S2CSalesOrderStack does not exist'.
2020-12-08T03:54:37.5265140Z Stack does not exist, switching to create stack mode
2020-12-08T03:54:37.5267421Z Testing to see if change set S2CSalesOrderStack11 associated with stack S2CSalesOrderStack exists
2020-12-08T03:54:38.3717711Z Test for existence of change set S2CSalesOrderStack11 returned error: 'Stack [S2CSalesOrderStack] does not exist'.
2020-12-08T03:54:38.3724223Z Loading template file from 'D:\a\r1\a\_AWS-S2C-ProcessMessage-CI\serverless-output\serverless-output.yaml'
2020-12-08T03:54:38.3730075Z No parameters file specified
2020-12-08T03:54:38.3731723Z Setting capability CAPABILITY_IAM for stack
2020-12-08T03:54:38.3732908Z Setting capability CAPABILITY_NAMED_IAM for stack
2020-12-08T03:54:38.3734631Z Setting capability CAPABILITY_AUTO_EXPAND for stack
2020-12-08T03:54:38.3735285Z Creating CREATE type change set S2CSalesOrderStack11
2020-12-08T03:54:46.5889859Z Change set creation request failed with error: 'undefined' { InternalFailure
2020-12-08T03:54:46.5891500Z     at constructor.extractError (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:88282)
2020-12-08T03:54:46.5892456Z     at constructor.callListeners (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:108520)
2020-12-08T03:54:46.5893265Z     at constructor.emit (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:108230)
2020-12-08T03:54:46.5896438Z     at constructor.emitEvent (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:183886)
2020-12-08T03:54:46.5897267Z     at constructor.e (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:179393)
2020-12-08T03:54:46.5898003Z     at r.runTo (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:185728)
2020-12-08T03:54:46.5898720Z     at D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:185934
2020-12-08T03:54:46.5899455Z     at constructor.<anonymous> (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:179663)
2020-12-08T03:54:46.5900239Z     at constructor.<anonymous> (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:183942)
2020-12-08T03:54:46.5901203Z     at constructor.callListeners (D:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99.8.0\CloudFormationCreateOrUpdateStack.js:2:108626)
2020-12-08T03:54:46.5901689Z   message: undefined,
2020-12-08T03:54:46.5902055Z   code: 'InternalFailure',
2020-12-08T03:54:46.5902486Z   time: 2020-12-08T03:54:46.559Z,
2020-12-08T03:54:46.5903062Z   requestId: '26a7ef25-1e18-4e00-8721-fd07bbd90a53',
2020-12-08T03:54:46.5903486Z   statusCode: 500,
2020-12-08T03:54:46.5903851Z   retryable: true }
2020-12-08T03:54:46.5962341Z ##[error]InternalFailure
2020-12-08T03:54:46.6025994Z ##[section]Finishing: Create/Update Stack: S2CSalesOrderStack

您可以按照以下步骤解决问题:

首先检查用于创建AWS Credentials服务连接的AWS账户是否有cloudformation:DescribeStackscloudformation:DescribeStackEvents permissions。如果您使用 IAM 角色创建 AWS Credentials 服务连接。您需要确保将上述权限分配给该角色。参见 here

确保你 select 正确 AWS Region。 CloudFormation 是区域特定的。

手动删除存在的堆栈,或使用 AWS CloudFormation 删除堆栈 在创建之前删除堆栈的任务。请参阅以下线程以获取信息。

Stack does not exist" while creating a new stack

Stack with id does not exist

事实证明这是 YAML 模板本身的多个小语法错误,例如 Ref 参数的使用方式。不幸的是,错误消息并不能真正帮助发现问题,另外 SAM CLI 验证命令确认模板有效。

尽管如此,现在有了固定且有效的无服务器 YAML 模板,管道仍在运行。