CodePipeline CloudFormation 模板配置

CodePipeline CloudFormation Template configuration

我正在尝试使用 CodePipeline 中的 CloudFormation 模板配置字段。如果您在 CodePipeline 中编辑 CloudFormation,它看起来像这样:

如果我的 InputArtifactNameMyAppBuild 并且我在 cfg-prd.json 中有一个 CloudFormation 配置文件,我希望我可以输入 MyAppBuild::cfg-prd.json 并让它获取它。

我收到有关模板文件无效的错误消息,即使它是手动工作的:

--parameters cfg-prd.json

请注意 Template Configuration File has a different JSON structure than the format accepted by the --parameters option to aws cloudformation create-stack:

{
  "Parameters" : {
    "NameOfTemplateParameter" : "ValueOfParameter",
    ...
  },
  "StackPolicy" : {
    "Statement" : [
      StackPolicyStatement
    ]
  }
}

了解 Cloudformation 布局应该是什么的一个好技巧是创建一个您知道可以工作的管道。然后使用CLI提取cloudformation模板。

aws codepipeline get-pipeline --name <pipelinename>

您将获得 Codepipeline 资源的 JSON。需要进行一些更改,但从这里您可以准确地看到语法应该是什么,并从那里参数化您的模板并以编程方式创建 Codepipelines。