Original links
https://www.terraform.io/docs/configuration/expressions.html

terraform language

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Using Locals(available in terraform 0.10.3 or later) & interpolation

locals {
  //Put all common tags here
  common_tags = "${map(
                        "${oci_identity_tag_namespace.tag_namespace1.name}.${oci_identity_tag.tag1.name}","value",
                        "HumanResources.Environment", "Production",
                        "Operations.Project", "Beta"
                        )}"
}

resource "oci_core_instance" t {
  .
  .
  .

  freeform_tags = "${map("key${count.index}", "value${count.index}",
        "domain", "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[var.AD - 1],"name")}"
        )}"

  defined_tags = "${merge(
                        local.common_tags,
                        map(
                            "${oci_identity_tag_namespace.tag_namespace1.name}.${oci_identity_tag.tag2.name}", "awesome-tag-example"
                        )
                    )}"

}

Searching for docs and examples

1
le tf | grep -i example | ead -i resource

asciinema recording

1
ewwlinks +/"ยป map Function" "https://www.terraform.io/docs/configuration/functions/map.html"
1
map("a", "b", "c", "d")
{
  "a" = "b"
  "c" = "d"
}
1
map("a", "b", "c")

Error: Error in function call

  on <console-input> line 1:
  (source code not available)

Call to function "map" failed: map requires an even number of two or more
arguments, got 3.