Skip to content

Commit f647f2e

Browse files
committed
chore: better environment variable format
1 parent 69c159a commit f647f2e

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ locals {
3636
dockerLabels = jsonencode(var.dockerLabels)
3737
dockerSecurityOptions = jsonencode(var.dockerSecurityOptions)
3838
entryPoint = jsonencode(var.entryPoint)
39-
environment = jsonencode(var.environment)
4039
extraHosts = jsonencode(var.extraHosts)
4140

41+
environment = jsonencode(var.environment != {} ? [for k, v in var.environment : { "name" : k, "value" : v }] : [])
4242
healthCheck = replace(jsonencode(var.healthCheck), local.classes["digit"], "$1")
4343

4444
links = jsonencode(var.links)

test/varfile.tfvars

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
environment = [
2-
{
3-
name = "AWS_DEFAULT_REGION"
4-
value = "us-east-1"
5-
},
6-
]
1+
environment = {
2+
"AWS_DEFAULT_REGION" = "us-east-1"
3+
}
74

85
family = "default"
96

variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ variable "entryPoint" {
4949
}
5050

5151
variable "environment" {
52-
default = []
52+
default = {}
5353
description = "The environment variables to pass to a container"
54-
type = list(map(string))
54+
type = map(string)
5555
}
5656

5757
variable "essential" {

0 commit comments

Comments
 (0)