将地图变量作为字符串传递到Terraform中的CodePipeline Environment Variables部分

发布于 2025-02-08 09:59:55 字数 615 浏览 3 评论 0原文

我正在尝试通过下面的图形变量:

variables "egress_ports" {
type = map(any)
default = {
"from_port" = 8443
"to_port" = 8443
}
description = "e-gress required by pipeline"
}

以下codepipeline的环境变量部分

<stages>
{
EnvironmentVariables = jsonencode(var.egress_ports)
}

在我尝试这样的情况下, 。 有人可以帮助如何传递它。

这是我正在尝试的环境变量部分::

EnvironmentVariables = templatefile("./pre-req.tmpl", {pipeline_name = var.pipeline_name, app_id = var.app_id, **egress_ports = jsonencode(var.egress_ports)** })

如果没有egress_ports变量,一切正常,因为那是唯一的映射类型。请帮忙。

谢谢

I am trying to pass a map variable per below :

variables "egress_ports" {
type = map(any)
default = {
"from_port" = 8443
"to_port" = 8443
}
description = "e-gress required by pipeline"
}

into Environment variable section of codepipeline in terraform per below

<stages>
{
EnvironmentVariables = jsonencode(var.egress_ports)
}

When i try like this.. getting the error that EnvironmentVariable section requires json array of strings.
Could someone please help how to pass it in.

Here is the Environment Variable section i am trying ::

EnvironmentVariables = templatefile("./pre-req.tmpl", {pipeline_name = var.pipeline_name, app_id = var.app_id, **egress_ports = jsonencode(var.egress_ports)** })

Everything works fine without egress_ports variable, as that is the only one which is map type. please help.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌逼全场 2025-02-15 09:59:55

您可能需要转换Terraform变量输入以遵循此格式,然后将其传递到Environment Variables中。

[
   {"name": "from_port", "value": "8443", "type": "PLAINTEXT"},
   {"name": "to_port", "value": "8443", "type": "PLAINTEXT"},
]

you may need to transform your terraform variable input to follow this format and then pass it into EnvironmentVariables.

[
   {"name": "from_port", "value": "8443", "type": "PLAINTEXT"},
   {"name": "to_port", "value": "8443", "type": "PLAINTEXT"},
]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文