微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CloudFormation 更新堆栈

如何解决CloudFormation 更新堆栈

我有一个最初从 CloudFormation 模板创建的堆栈。当我将文件保存到我的 s3 存储桶时,我需要在 node.js 中添加一些动态标签。这是我的代码

let date = new Date();
let currentDate = date.toISOString();

let cloudFormationParams = {
    StackName: 'name-of-stack-created-from-cloud-formation',Tags: [
      {
        Key: 'CurrentDate',Value: currentDate
      },/* more items */
    ],UsePrevIoUstemplate: true 
  };

  await cloudformation.updateStack(cloudFormationParams,(err,data) => {
    if (err) {
        console.log(err,err.stack); // an error occurred
        return { status: "error" }
    } else {
        console.log(data);           // successful response

    }
}).promise();

这给了我错误 "ValidationError","errorMessage":"Stack: is in UPDATE_IN_PROGRESS state and can not be updated.

谁能告诉我我做错了什么?

解决方法

Nodejs 提供了 wait_for 方法,允许您在代码中等待,如果感兴趣的话,堆栈处于该状态。您可以等待的可能状态是:

  • stackExists
  • stackCreateComplete
  • stackUpdateComplete
  • 等等。

因此,您可以在对堆栈执行进一步操作之前将 execute(...)wait_for 添加到您的代码中。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。