package.json
{
"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"
}
}
以下代码
try {
await cloudFormationService
.createStack({
StackName: fullStackName,
TemplateBody: merged
})
.promise();
} catch (e) {
throw e;
}
结果出现以下错误
(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
添加功能try {
await cloudFormationService
.createStack({
StackName: fullStackName,
TemplateBody: merged,
Capabilities: [
CAPABILITY_IAM
]
})
.promise();
} catch (e) {
throw e;
}
我得到以下错误的结果
(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.
答案 0 :(得分:0)
根据 AWS 文档,如果您拥有具有自定义名称的 IAM 资源,则必须指定 CAPABILITY_NAMED_IAM。 Link
try {
await cloudFormationService
.createStack({
StackName: fullStackName,
TemplateBody: merged,
Capabilities: [
"CAPABILITY_NAMED_IAM"
]
})
.promise();
} catch (e) {
throw e;
}