Amazon web services 将AWS信息从CloudFormation导入到CodeBuild
我在AWS中有一个与Codestar、CodeBuild、CloudFormation等的管道 我试图弄清楚如何从返回到代码构建步骤的CloudFormation步骤中获取信息。让我把它分解一下:Amazon web services 将AWS信息从CloudFormation导入到CodeBuild,amazon-web-services,amazon-s3,aws-codebuild,amazon-cloudformation,Amazon Web Services,Amazon S3,Aws Codebuild,Amazon Cloudformation,我在AWS中有一个与Codestar、CodeBuild、CloudFormation等的管道 我试图弄清楚如何从返回到代码构建步骤的CloudFormation步骤中获取信息。让我把它分解一下: 我有一个用于代码构建的buildspec.yml # buildspec.yml ... phases: ... build: commands: - aws cloudformation package --region $REGION --template template.
buildspec.yml
# buildspec.yml
...
phases:
...
build:
commands:
- aws cloudformation package --region $REGION --template template.yml --s3-bucket $S3_BUCKET --output-template $OUTPUT_TEMPLATE
模板.yml
# template.yml
...
S3BucketAssets:
Type: AWS::S3::Bucket
...
buildspec.yml
中的步骤2,我想将项目推送到刚刚在CloudFormation模板中创建的S3 bucket中。但是,我不知道如何从CloudFormation模板获取动态创建的S3 bucket名称。我想要类似于:
# buildspec.yml
...
phases:
...
build:
commands:
# this is the same step as shown above
- aws cloudformation package --region $REGION --template template.yml --s3-bucket $S3_BUCKET --output-template $OUTPUT_TEMPLATE
# this is the new step
- aws s3 sync dist_files/ s3://{NAME_OF_THE_NEW_S3_BUCKET}
我知道在CloudFormation模板中,您可以使用类似
的东西引用S3 bucket名称!GetAtt[ClientWebAssets,WebsiteURL]
。但是,我不知道如何将这些信息从cloudformation模板中提取出来并返回到codebuild模板中。您可以使用CodePipeline。第一阶段是通过cloudformation部署应用程序,输出工件是堆栈创建输出