Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 将AWS信息从CloudFormation导入到CodeBuild_Amazon Web Services_Amazon S3_Aws Codebuild_Amazon Cloudformation - Fatal编程技术网

Amazon web services 将AWS信息从CloudFormation导入到CodeBuild

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.

我在AWS中有一个与Codestar、CodeBuild、CloudFormation等的管道

我试图弄清楚如何从返回到代码构建步骤的CloudFormation步骤中获取信息。让我把它分解一下:

  • 我有一个用于代码构建的
    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
     ...
    
  • 此时,它将为S3 bucket创建一个唯一的名称。令人惊叹的。现在,对于CodeBuild的
    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}
    
  • 如何获得动态命名的S3 bucket,以便推送它


    我知道在CloudFormation模板中,您可以使用类似
    的东西引用S3 bucket名称!GetAtt[ClientWebAssets,WebsiteURL]
    。但是,我不知道如何将这些信息从cloudformation模板中提取出来并返回到codebuild模板中。

    您可以使用CodePipeline。第一阶段是通过cloudformation部署应用程序,输出工件是堆栈创建输出