简体   繁体   English

AWS CodePipeline:在CodeBuild中获取CloudFormation输出

[英]AWS CodePipeline: Get CloudFormation outputs in CodeBuild

I'm learning some DevOps techniques using AWS CodePipeline (Cloudformation and CodeBuild). 我正在学习使用AWS CodePipeline(Cloudformation和CodeBuild)的一些DevOps技术。

My (simplified) pipeline is this: 我的(简化的)管道是这样的:

  1. Push to github repo triggers pipeline 推送到github repo触发管道
  2. CloudFormation builds/updates backend infrastructure CloudFormation构建/更新后端基础架构
  3. CodeBuild does some additional work CodeBuild还有一些其他工作

At the moment, CloudFormation outputs the following: 目前,CloudFormation输出以下内容:

Outputs:
  RestApiId:
    Value: !Ref ApiGateway
    Description: 'API Id'

Question: How can I get the ApiGateway ID in CloudBuild? 问题:如何在CloudBuild中获取ApiGateway ID?

According to: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-parameter-override-functions.html 根据: https : //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-parameter-override-functions.html

You can specify CodePipeline step like this (from documentation): 您可以这样指定CodePipeline步骤(来自文档):

- Name: CreateTestStackA
  Actions:
    - Name: CloudFormationCreate
      ActionTypeId:
        Category: Deploy
        Owner: AWS
        Provider: CloudFormation
        Version: '1'
      Configuration:
        ActionMode: CREATE_UPDATE
        Capabilities: CAPABILITY_IAM
        OutputFileName: TestOutput.json
        RoleArn: !GetAtt [CFNRole, Arn]
        StackName: StackA
        TemplateConfiguration: TemplateSource::test-configuration.json
        TemplatePath: TemplateSource::teststackA.yaml
      InputArtifacts:
        - Name: TemplateSourceA
      OutputArtifacts:
        - Name: StackAOutput
      RunOrder: '1'

So in Configuration you need to add OutputFileName parameter and specify output artifact name. 因此,在Configuration您需要添加OutputFileName参数并指定输出工件名称。 Then you can use that artifact as an input to CodeBuild. 然后,您可以将该工件用作CodeBuild的输入。 In output file (TestOutput.json) you will have a dictionary where key is output name and value is output value. 在输出文件(TestOutput.json)中,您将有一个字典,其中的键是输出名称,值是输出值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM