-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputs.tf
16 lines (14 loc) · 981 Bytes
/
outputs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# The following hacks are required to overcome TF automatic type conversions which lead to issues with the resulting json types.
# Conversion happens by using the built-in `replace` function in this order:
# - Convert `""`, `{}`, `[]`, and `[""]` to `null`
# - Convert `"true"` and `"false"` to `true` and `false`
# - Convert quoted numbers (e.g. `"123"`) to `123`.
# Environment variables are kept as strings.
locals {
encoded_container_definitions = "${replace(replace(replace(jsonencode(local.container_definitions), "/(\\[\\]|\\[\"\"\\]|\"\"|{})/", "null"), "/\"(true|false)\"/", "$1"), "/\"([0-9]+\\.?[0-9]*)\"/", "$1")}"
encoded_environment_variables = "${jsonencode(local.environment)}"
}
output "json" {
description = "JSON encoded container definitions for use with other terraform resources such as aws_ecs_task_definition."
value = "${replace(local.encoded_container_definitions, "/\"environment_sentinel_value\"/", local.encoded_environment_variables)}"
}