【问题标题】:CloudFormation passing parameters from CodePipelineCloudFormation 从 CodePipeline 传递参数
【发布时间】:2018-02-25 06:33:17
【问题描述】:

我有一个 SAM 应用程序和一个 CodePipeline 设置来部署它。我想将参数从我的管道传递到 SAM 的 YAML 文件中。我尝试使用ParameterOverrides,但似乎仍然得到:

参数:[AppName] 必须有值(服务:AmazonCloudFormation;状态代码:400;错误代码:ValidationError;请求 ID:46d1dfd6-9a9a-11e7-a59d-999618d6a174)

我的sam.yml 参数定义

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
  AppName:
    Type: String
    Description: Prefix for resources

定义参数的部分覆盖:

    - Name: ExecuteChangeSet
      Actions:
      - Name: Lambda
        ActionTypeId:
          Category: Deploy
          Owner: AWS
          Version: 1
          Provider: CloudFormation
        Configuration:
          ActionMode: CHANGE_SET_EXECUTE
          ChangeSetName: !Sub
            - '${PipelineName}-lambda'
            - {PipelineName: !Ref PipelineName}
          StackName: !Sub
            - '${PipelineName}-lambda'
            - {PipelineName: !Ref PipelineName}
          ParameterOverrides: !Sub '{"AppName": "${PipelineName}-lambda"}'

这有什么问题吗?

【问题讨论】:

  • 你让它工作了吗?

标签: amazon-web-services amazon-cloudformation aws-codepipeline


【解决方案1】:

您似乎正试图在 CHANGE_SET_EXECUTE 操作模式期间应用 ParameterOverrides。如果我没记错的话,在后台,这映射到 CloudFormations ExecuteChangeSet 操作,它没有 Parameters 属性。

解决方案是在创建更改集时应用参数。这将在 CodePipeline 中以CHANGE_SET_REPLACE 操作模式完成。或者,您可以查看CREATE_UPDATE。查看AWS CloudFormation Configuration Properties了解更多详情。

这是一个创建然后执行更改集的示例

- Name: CreateChangeSet
  Actions:
    - Name: Lambda
      ActionTypeId:
        Category: Deploy
        Owner: AWS
        Version: 1
        Provider: CloudFormation
      InputArtifacts:
        - Name: BuildOutputArtifact
      Configuration:
        ActionMode: CHANGE_SET_REPLACE
        ChangeSetName: !Sub
          - '${PipelineName}-lambda'
          - {PipelineName: !Ref PipelineName}
        StackName: !Sub
          - '${PipelineName}-lambda'
          - {PipelineName: !Ref PipelineName}
        ParameterOverrides: !Ref ProjectParameterOverrides
        TemplatePath: BuildOutputArtifact::SamDeploymentTemplate.yaml
- Name: ExecuteChangeSet
  Actions:
  - Name: Lambda
    ActionTypeId:
      Category: Deploy
      Owner: AWS
      Version: 1
      Provider: CloudFormation
    Configuration:
      ActionMode: CHANGE_SET_EXECUTE
      ChangeSetName: !Sub
        - '${PipelineName}-lambda'
        - {PipelineName: !Ref PipelineName}
      StackName: !Sub
        - '${PipelineName}-lambda'
        - {PipelineName: !Ref PipelineName}

【讨论】:

  • 什么是 ProjectParameterOverrides?
猜你喜欢
  • 2019-01-06
  • 2019-04-03
  • 2020-11-06
  • 2019-05-12
  • 2022-01-19
  • 2020-06-28
  • 2017-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多