Typescript AWS CDK新合成器版本
我已经为新的“StyleStackSynthesis”启动了CDKToolKit堆栈 我将此字段添加到cdk.jsonTypescript AWS CDK新合成器版本,typescript,amazon-web-services,aws-cdk,Typescript,Amazon Web Services,Aws Cdk,我已经为新的“StyleStackSynthesis”启动了CDKToolKit堆栈 我将此字段添加到cdk.json "@aws-cdk/core:newStyleStackSynthesis": "true" 此CDKToolKit堆栈已成功部署到AWS。 我用过这个命令 cdk bootstrap --toolkit-stack-name custom-cdktoolkit cdk deploy --toolkit-stack-name cus
"@aws-cdk/core:newStyleStackSynthesis": "true"
此CDKToolKit堆栈已成功部署到AWS。
我用过这个命令
cdk bootstrap --toolkit-stack-name custom-cdktoolkit
cdk deploy --toolkit-stack-name custom-cdktoolkit
但是现在我尝试使用CDKToolKit堆栈来部署我的CDK应用程序堆栈,我收到了这个消息
Error: Could not assume role in target account (did you bootstrap the environment with the right '--trust's?)
我使用这个命令
cdk bootstrap --toolkit-stack-name custom-cdktoolkit
cdk deploy --toolkit-stack-name custom-cdktoolkit
我还将其添加到cdk应用程序堆栈中
"@aws-cdk/core:newStyleStackSynthesis": "true"
我应该添加一些额外的配置等吗?我刚刚重播了你在一个全新的、未经改动的帐户上发布的所有内容 我使用的是AWS CDK版本:1.70.0(最新版本为2020/10/28)
cdk.json
中添加“@aws cdk/core:newStyleStackSynthesis”:“true”
//文件:lib/cdk-playerly-stack.ts
从“@aws cdk/core”导入*作为cdk;
将*作为s3从“@aws cdk/aws-s3”导入;
导出类CdkPlaygroundStack扩展了cdk.Stack{
构造函数(作用域:cdk.Construct,id:string,props?:cdk.StackProps){
超级(范围、id、道具);
新的s3.Bucket(这个“id”{
访问控制:s3.BucketAccessControl.PRIVATE,
加密:s3.BucketEncryption.s3_管理,
版本:false,
blockPublicAccess:s3.blockPublicAccess.BLOCK_ALL,
});
}
}
//文件:app/app.ts
#!/usr/bin/env节点
导入“源地图支持/注册”;
从“@aws cdk/core”导入*作为cdk;
从“../lib/cdk playgroundstack”导入{CdkPlaygroundStack};
const app=new cdk.app();
//没有跨帐户环境参数(如account)传递到堆栈!
新的CdkPlaygroundStack(应用程序“CdkPlaygroundStack”);
- 更新至CDK的当前版本
- 检查您的堆栈创建,如果确实没有参数/道具被传递到其他帐户,比如您在AWS概要文件/环境变量中使用的帐户。跨帐户部署需要特定的引导设置,因此我专门询问了这一点
- 删除引导的CloudFormation堆栈
- 正是我所做的
cdktoolkit…
开头,在“资源”中只包含一个S3存储桶否,只有一个新的custome cdktoolkit
堆栈,其中包含S3、角色、存储库和密钥
cdk deploy --toolkit-stack-name custom-cdktoolkit
CdkPlaygroundStack: deploying...
[0%] start: Publishing dbfc18c149132627081b768fbbfc4bc345aeba4259514174fcd302d8b3926a90:current_account-current_region
[100%] success: Published dbfc18c149132627081b768fbbfc4bc345aeba4259514174fcd302d8b3926a90:current_account-current_region
CdkPlaygroundStack: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (3/3)
✅ CdkPlaygroundStack
Stack ARN:
arn:aws:cloudformation:us-east-1:xxxxxxx:stack/CdkPlaygroundStack/9b8d4460-1940-11eb-abd9-0e794c84352f