首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cloudformation :需要功能:[CAPABILITY_IAM]

Cloudformation :需要功能:[CAPABILITY_IAM]
EN

Stack Overflow用户
提问于 2019-01-14 23:00:18
回答 1查看 392关注 0票数 0

package.json

代码语言:javascript
复制
{
  "name": "env",
  "version": "1.0.0",
  "description": ".history",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "manual": "node manual.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "aws-sdk": "^2.209.0",
    "commander": "^2.15.0",
    "deepmerge": "^2.1.0"
  }
}

下面的代码

代码语言:javascript
复制
 try {
      await cloudFormationService
        .createStack({
          StackName: fullStackName,
          TemplateBody: merged
        })
        .promise();
    } catch (e) {
      throw e;
    }

具有以下错误的结果

代码语言:javascript
复制
(node:7452) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): InsufficientCapabilitiesException: Requires capabilities : [CAPABILITY_IAM]
(node:7452) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit

一旦我根据这个https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFormation.html添加了功能

代码语言:javascript
复制
try {
  await cloudFormationService
    .createStack({
      StackName: fullStackName,
      TemplateBody: merged,
      Capabilities: [
        CAPABILITY_IAM
      ]
    })
    .promise();
} catch (e) {
  throw e;
}

我得到的结果如下所示

代码语言:javascript
复制
(node:11840) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: CAPABILITY_IAM is not defined
(node:11840) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
EN

回答 1

Stack Overflow用户

发布于 2021-03-27 16:09:42

根据亚马逊网络服务文档,如果您有自定义名称的IAM资源,则必须指定CAPABILITY_NAMED_IAMLink

代码语言:javascript
复制
try {
      await cloudFormationService
        .createStack({
          StackName: fullStackName,
          TemplateBody: merged,
          Capabilities: [
            "CAPABILITY_NAMED_IAM"
          ]
        })
        .promise();
    } catch (e) {
      throw e;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54183911

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档