当前用于Javascript的AWS sdk不支持
不
目前有一个部署方法,但是AWS CLI的
deploy
命令是一个包装器:
通过创建并执行更改集来部署指定的AWS CloudFormation模板
const CloudformationInstance = new Cloudformation(accessParams)
CloudformationInstance.createChangeSet(changeSetParams, (err, data) => {
if (err) throw new Error(err, err.stack)
console.info('Succesfully created the ChangeSet: ', data)
CloudformationInstance.waitFor('changeSetCreateComplete', {ChangeSetName: config.changeSetName}, (err, data) => {
if (err) throw new Error(err, err.stack)
const { StackName } = data.Stacks[0]
CloudformationInstance.executeChangeSet({ StackName, ChangeSetName }, (err, data) => {
if (err) throw new Error(err, err.stack)
console.info('Succesfully finished creating the set: ', data)
})
})
})
注:
changeSetType(changeSetParams的一部分)需要显式定义为
“创建或更新”。因此,使用类似于:
const upsertParam = await CloudformationInstance.describeStacks(params, (err, data) => {
if(err) return 'CREATE'
return 'UPDATE'
}