Typescript AWS CDK新合成器版本

Typescript 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

我已经为新的“StyleStackSynthesis”启动了CDKToolKit堆栈 我将此字段添加到cdk.json

"@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”
  • 运行cdk引导程序--toolkit堆栈名自定义cdktoolkit。这是你在你的岗位上下达的命令
  • 好的,让我们快速看一下示例堆栈(如您在评论中所述,没有任何跨帐户访问):
  • //文件: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引导名称)
  • 正如您所看到的,没有任何冲突,而且与您提供的信息相比,很难验证发生了什么

    你能做什么

    • 更新至CDK的当前版本
    • 检查您的堆栈创建,如果确实没有参数/道具被传递到其他帐户,比如您在AWS概要文件/环境变量中使用的帐户。跨帐户部署需要特定的引导设置,因此我专门询问了这一点
    • 删除引导的CloudFormation堆栈
    • 正是我所做的

    您是否从一个帐户部署到另一个帐户?@mchlfchr这是同一个帐户您是否有使用旧引导机制的现有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