【问题标题】:Conditionally create CodePipeline actions based on CloudFormation conditions - not working根据 CloudFormation 条件有条件地创建 CodePipeline 操作 - 不起作用
【发布时间】:2019-05-13 10:04:26
【问题描述】:

Conditionally create CodePipeline actions based on CloudFormation conditions

根据上面的链接 fn::if 在 aws codepipeline 中工作,但不幸的是它不适合我

下面是我的代码:

- !If
  - testCondition
  - Name: SwitchEnvironment
    ActionTypeId:
      Category: Build
      Owner: AWS
      Provider: CodeBuild
      Version: 1
    Configuration:
      ProjectName: !Ref SwitchDeployment
    InputArtifacts:
    - Name: Source
    OutputArtifacts:
    - Name: SwitchDeployment
    RunOrder: 1
  - !Ref AWS::NoValue

如果我将此条件设置为 false,cloudformation 会显示“属性操作不能为空”。

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    当我将 !IF 语句放入 Actions 部分时,我遇到了相同的错误消息。根据 AWS 文档 (link to AWS docs),管道阶段至少需要 1 个操作。因此,如果条件评估为假,则将有 0 个操作并导致该错误。 以下对我有用(适用于您的示例):

    - !If
      - testCondition
      - Name: SwitchEnvironment
        Actions:
          - Name: NameOfYourConditionalAction
            ActionTypeId:
              Category: Build
              Owner: AWS
              Provider: CodeBuild
              Version: 1
            Configuration:
              ProjectName: !Ref SwitchDeployment
            InputArtifacts:
              - Name: Source
            OutputArtifacts:
              - Name: SwitchDeployment
            RunOrder: 1
      - !Ref AWS::NoValue
    

    【讨论】:

      猜你喜欢
      • 2017-06-04
      • 1970-01-01
      • 1970-01-01
      • 2023-02-23
      • 2022-06-28
      • 1970-01-01
      • 1970-01-01
      • 2019-05-07
      • 2022-01-11
      相关资源
      最近更新 更多