首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将参数传递给CodePipeline

将参数传递给CodePipeline
EN

Stack Overflow用户
提问于 2020-01-27 19:56:59
回答 2查看 1.5K关注 0票数 2

我为我的堆栈创建了代码行,在提交特定分支时,应该会触发更新堆栈,一切正常,但问题出在参数上,特别是秘密参数。这是我的问题: 1.我如何在ParameterOverrides中省略“丑陋的”JSON字符串,现在,没有问题,但如果我将覆盖30个以上的参数,它将是一个长字符串,我可以包含带有参数的JSON文件吗?如果是,我该怎么做?

代码语言:javascript
运行
复制
 "ResRootStackCodePipeline": {
  "Type": "AWS::CodePipeline::Pipeline",
  "DependsOn": [
    "ResRootStackServerI"
  ],
  "Properties": {
    "Name": "AutoProjectCodePipeline",
    "RestartExecutionOnUpdate": "true",
    "RoleArn": {
      "Fn::Join": [
        "",
        [
          "arn:aws:iam::",
          {
            "Ref": "AWS::AccountId"
          },
          ":role/service-role/AWSCodePipelineServiceRole"
        ]
      ]
    },
    "ArtifactStore": {
      "Type": "S3",
      "Location": "bucket-codepipeline-test"
    },
    "Stages": [
      {
        "Name": "APSource",
        "Actions": [
          {
            "Name": "APSourceProcess",
            "ActionTypeId": {
              "Category": "Source",
              "Owner": "ThirdParty",
              "Provider": "GitHub",
              "Version": "1"
            },
            "RunOrder": 1,
            "Configuration": {
              "Branch": "instances-test",
              "OAuthToken": "xxx",
              "Owner": "muume",
              "PollForSourceChanges": "true",
              "Repo": "autoproject-aws-infra"
            },
            "OutputArtifacts": [
              {
                "Name": "APGithubArtifact"
              }
            ]
          }
        ]
      },
      {
        "Name": "APDeploy",
        "Actions": [
          {
            "Name": "APUpdateProcess",
            "ActionTypeId": {
              "Category": "Deploy",
              "Owner": "AWS",
              "Provider": "CloudFormation",
              "Version": "1"
            },
            "RunOrder": 1,
            "Configuration": {
              "ActionMode": "CREATE_UPDATE",
              "RoleArn": {
                "Fn::Join": [
                  "",
                  [
                    "arn:aws:iam::",
                    {
                      "Ref": "AWS::AccountId"
                    },
                    ":role/CloudFormationRole"
                  ]
                ]
              },
              "StackName": {
                "Ref": "AWS::StackName"
              },
              "ParameterOverrides": { "Fn::Join": [ "", [
                "{\"ParaNamePrefix\": \"tescik\",\"ParaTemplateURI\": \"https://localhost.xx/\",\"ParaServerInstanceTypeFront\": \"t2.medium\"}"
                ]]},
              "TemplatePath": "APGithubArtifact::instances-test/Stack_Root_I.json",
              "TemplateConfiguration": "APGithubArtifact::instances-test/simple_configuration.json"

            },
            "OutputArtifacts": [],
            "InputArtifacts": [
              {
                "Name": "APGithubArtifact"
              }
            ]
          }
        ]
      }
    ]
  }
}

也许你看到了解决这个问题的其他解决方案?

EN

回答 2

Stack Overflow用户

发布于 2020-04-22 22:40:27

使用YAML。对于CloudFormation来说,它比JSON要好得多。下面是一个参数重写的示例:

代码语言:javascript
运行
复制
ParameterOverrides: |-
          {
            "SomeParameterOverride": "xxx",
            "SomeOtherParameterOverride":"yyy"
          }

您可以使用Cloudformation designer或类似如下的站点轻松地将现有的JSON转换为YAML:https://www.json2yaml.com/

YAML还允许对模板中的其他资源和参数进行注释和轻松引用。

票数 1
EN

Stack Overflow用户

发布于 2020-01-27 22:44:37

根据the documentation的说法

我们建议您使用模板配置文件来指定大多数参数值。使用参数替代仅指定动态参数值。在运行管道之前,动态参数是未知的。

请记住,参数覆盖的大小也有1KB的限制。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59930697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档