AWS CodePipeline:在CodeBuild中获取CloudFormation输出 [英] AWS CodePipeline: Get CloudFormation outputs in CodeBuild

查看:114
本文介绍了AWS CodePipeline:在CodeBuild中获取CloudFormation输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS CodePipeline(Cloudformation和CodeBuild)学习一些DevOps技术。

I'm learning some DevOps techniques using AWS CodePipeline (Cloudformation and CodeBuild).

我的(简化的)管道是:

My (simplified) pipeline is this:


  1. 推送到github存储库触发器管道

  2. CloudFormation构建/更新后端基础结构

  3. CodeBuild可以一些其他工作

目前,CloudFormation输出以下内容:

At the moment, CloudFormation outputs the following:

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

问题:如何在CloudBuild中获取ApiGateway ID?

Question: How can I get the ApiGateway ID in CloudBuild?

推荐答案

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

您可以这样指定CodePipeline步骤(来自文档):

You can specify CodePipeline step like this (from documentation):

- 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'

配置,您需要添加 OutputFileName 参数并指定输出工件n阿美然后,您可以将该工件用作CodeBuild的输入。在输出文件(TestOutput.json)中,您将有一个字典,其中的键是输出名称,值是输出值。

So in Configuration you need to add OutputFileName parameter and specify output artifact name. Then you can use that artifact as an input to CodeBuild. In output file (TestOutput.json) you will have a dictionary where key is output name and value is output value.

这篇关于AWS CodePipeline:在CodeBuild中获取CloudFormation输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆