gpt4 book ai didi

amazon-web-services - Codepipline 构建步骤的 AWS Cloudformation 环境变量

转载 作者:行者123 更新时间:2023-12-03 07:26:15 27 4
gpt4 key购买 nike

我一直在尝试向 YAML cloudformation 模板添加一个简单的环境变量。我在创建时将其作为参数传递给模板,无论它是“生产”还是“登台”,并且希望将其传递到我的代码管道的“构建”部分。

        - Name: "Build"
Actions:
- Name: "Build"
ActionTypeId:
Category: "Build"
Owner: "AWS"
Provider: "CodeBuild"
Version: "1"
Configuration:
ProjectName: !Ref CodeBuildProject
# EnvironmentVariables:
# - Name: "CURRENT_ENVIRONMENT"
# Type: PLAINTEXT
# Value: !Ref CodeEnvironment
# EnvironmentVariables: !Sub |
# "{\"name\":\"CURRENT_ENVIRONMENT\", \"type\": \"PLAINTEXT\" \"value\": \"${CodeEnvironment}\"}"
EnvironmentVariables: "{\"name\":\"CURRENT_ENVIRONMENT\", \"type\": \"PLAINTEXT\" \"value\": \"${CodeEnvironment}\"}"
InputArtifacts:
- Name: "SourceArtifact"
OutputArtifacts:
- Name: "secondary_artifact_name_1"
- Name: "secondary_artifact_name_2"
Region: !Ref AWS::Region
Namespace: "BuildVariables"
RunOrder: 1

`

我尝试了几种不同的方式来传递“EnvironmentVariables”,但不断收到此错误:

操作“Build”configurationKey“EnvironmentVariables”的配置与预期格式不匹配。预期格式是遵循以下格式的 JSON 数组:[{"name": "string", "type": "string", "value": "string"}] (Service: AWSCodePipeline; Status Code: 400; Error代码:InvalidActionDeclarationException;请求 ID:fe7b8f6b-5410-48d2-b18f-f9377d1898cb;代理:null)

我已经找到了在 json 模板中执行此操作的方法,但在 yaml 模板中执行此操作时遇到了困难

最佳答案

EnvironmentVariables 应该是 JSON 数组,而不是普通 map 。所以应该是:

EnvironmentVariables: "[{\"name\":\"CURRENT_ENVIRONMENT\", \"type\": \"PLAINTEXT\" \"value\": \"${CodeEnvironment}\"}]"

关于amazon-web-services - Codepipline 构建步骤的 AWS Cloudformation 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74748524/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com