Skip to content

Commit 03eefb7

Browse files
jasonwalshjasonwalsh
authored andcommitted
docs: Add documentation to main.tf
1 parent dc0750b commit 03eefb7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

main.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
# The ternary operators in this module are mandatory. All composite types (e.g., lists and maps) require encoding to
2+
# pass as arguments to the Terraform `template_file`[1] data source The `locals.tf` file contains the encoded values of
3+
# the composite types defined in the ECS Task Definition[2]. Certain variables, such as `healthCheck`, `linuxParameters`
4+
# and `portMappings`, require the `replace` function since they contain numerical values. For example, given the
5+
# following JSON:
6+
#
7+
# -var 'portMappings=[{containerPort = 80, protocol = "TCP"}]'
8+
#
9+
# [
10+
# {
11+
# "containerDefinitions": [
12+
# {
13+
# "portMappings": [
14+
# {
15+
# "containerPort": 80,
16+
# "protocol": "TCP"
17+
# }
18+
# ]
19+
# }
20+
# ]
21+
# }
22+
# ]
23+
#
24+
# Since the `containerPort` and `hostPort`[3] fields are both integer types, then the `replace` function is necessary to
25+
# prevent quoting the value in strings. This issue is a known limitation in the Terraform `jsonencode`[4] function.
26+
#
27+
# - 1. https://www.terraform.io/docs/providers/template/d/file.html
28+
# - 2. https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html
29+
# - 3. https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html
30+
# - 4. https://github.com/hashicorp/terraform/issues/17033
31+
132
locals {
233
command = "${jsonencode(var.command)}"
334
dnsSearchDomains = "${jsonencode(var.dnsSearchDomains)}"

0 commit comments

Comments
 (0)