根据CloudFormation条件有条件地创建CodePipeline操作 [英] Conditionally create CodePipeline actions based on CloudFormation conditions

查看:74
本文介绍了根据CloudFormation条件有条件地创建CodePipeline操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用条件句为CodePipeline启用/禁用CloudFormation的各个部分:

Enable / disable sections of a CloudFormation for CodePipeline using Conditionals:

一旦构建了阶段并通过了Runscope测试,这将创建手动通知操作:

This creates a manual notification action once staging has been built and passed Runscope tests:

- InputArtifacts: []
      Name: !Join ["",[!Ref GitHubRepository, "-prd-approval"]]
      ActionTypeId:
        Category: Approval
        Owner: AWS
        Version: '1'
        Provider: Manual
      OutputArtifacts: []
      Configuration:
        NotificationArn: !GetAtt ["SNSApprovalNotification", "Outputs.SNSTopicArn"]
        ExternalEntityLink: OutputTestUrl
      RunOrder: 3

如何像其他CloudFormation资源一样启用/禁用此条件:。

How to enable/disable this like other CloudFormation resources with a Condition: .

操作步骤无法识别条件:参数

Action steps don't recognize Condition: param

我可以复制整个管道代码的2个副本有和没有,然后切换我创建的管道,但似乎应该有更好的方法。

I could make 2 copies of the whole pipeline code one with and one without and then toggle which pipeline I create but it seems like there should be a better way.

推荐答案

可以通过有条件地插入 AWS :: CodePipeline :: Pipeline 资源的操作 动作 列表,使用 Fn :: If 内部函数引用您的 条件 元素,当条件为true且 AWS :: NoValue (将删除属性,在这种情况下,将从列表中删除该项)

You should be able to accomplish this by conditionally inserting the AWS::CodePipeline::Pipeline Resource's Action into the Actions list using the Fn::If Intrinsic Function referencing your Conditions element, returning the Action when the Condition is true and AWS::NoValue (which removes the property, in this case removing the item from the list) when it is not true:

- !If
  - IsProdCondition
  - InputArtifacts: []
    Name: !Join ["",[!Ref GitHubRepository, "-prd-approval"]]
    ActionTypeId:
      Category: Approval
      Owner: AWS
      Version: '1'
      Provider: Manual
    OutputArtifacts: []
    Configuration:
      NotificationArn: !GetAtt ["SNSApprovalNotification", "Outputs.SNSTopicArn"]
      ExternalEntityLink: OutputTestUrl
    RunOrder: 3
  - !Ref AWS::NoValue

这篇关于根据CloudFormation条件有条件地创建CodePipeline操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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