问题描述
我正在使用AWS CodePipeline(Cloudformation和CodeBuild)学习一些DevOps技术。
I'm learning some DevOps techniques using AWS CodePipeline (Cloudformation and CodeBuild).
我的(简化的)管道是:
My (simplified) pipeline is this:
- 推送到github存储库触发器管道
- CloudFormation构建/更新后端基础结构
- 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?
推荐答案
根据:
您可以这样指定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输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!