簡體   English   中英

將AWS信息從CloudFormation導入到CodeBuild

[英]Importing AWS information from CloudFormation to CodeBuild

我在AWS中擁有Codestar,CodeBuild,CloudFormation等管道。

我試圖弄清楚如何從CloudFormation步驟返回CodeBuild步驟中獲取信息。 讓我分解一下:

  1. 我有一個buildspec.yml為CodeBuild

     # buildspec.yml ... phases: ... build: commands: - aws cloudformation package --region $REGION --template template.yml --s3-bucket $S3_BUCKET --output-template $OUTPUT_TEMPLATE 
  2. 上面使用我們的template.yml啟動了CloudFormation構建

     # template.yml ... S3BucketAssets: Type: AWS::S3::Bucket ... 
  3. 此時,它為S3存儲桶創建了唯一的名稱。 真棒。 現在,對於我在buildspec.yml的buildspec.yml中的步驟2,我想將項目推送到剛剛在CloudFormation模板中創建的S3存儲桶中。 但是,我不知道如何從CloudFormation模板獲取動態創建的S3存儲桶名稱。 我想要類似的東西:

     # 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} 

如何完成獲取動態命名的S3存儲桶以便可以推送到它?

我知道在CloudFormation模板中,您可以使用!GetAtt [ClientWebAssets, WebsiteURL]類的名稱引用S3存儲桶名稱。 但是,我不知道如何從cloudformation模板中獲取該信息並返回到代碼構建模板中。

您可以轉到使用CodePipeline。 第一階段是通過cloudformation部署應用程序,輸出工件是堆棧創建輸出

http://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#action-requirements

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM