<p>I have the following, relatively complicated piece of YAML:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: aws-auth
  namespace: kube-system
data:
  mapRoles: |
    - rolearn: ${aws_iam_role.tf-eks-node.arn}
      username: system:node:{{EC2PrivateDNSName}}
      groups:
        - system:bootstrappers
        - system:nodes
</code></pre>

<p>I now want to translate this into a Terraform-Kubernetes compatible resource, which consists exclusively of String, Lists and Maps. How do I do this? 
I found an example of how a LimitRange would look <a href="https://www.terraform.io/docs/providers/kubernetes/guides/getting-started.html" rel="nofollow noreferrer">here</a> using hyphens to signify a list:</p>

<pre><code>resource "kubernetes_limit_range" "example" {
    metadata {
        name = "terraform-example"
    }
    spec {
        limit {
            type = "Pod"
            max {
                cpu = "200m"
                memory = "1024M"
            }
        }
        limit {
            type = "PersistentVolumeClaim"
            min {
                storage = "24M"
            }
        }
        limit {
            type = "Container"
            default {
                cpu = "50m"
                memory = "24M"
            }
        }
    }
}
</code></pre>

<p>My current try for the mapRoles block is as follows:</p>

<pre><code>mapRole { rolearn = "${aws_iam_role.tf-eks-node.arn}"
      username = "system:node:{{EC2PrivateDNSName}}"
      groups = ["system:bootstrappers","system:nodes"]}
</code></pre>

<p>This is not correct because mapRoles is a list (because its singular element is a list element as demonstrated by the hyphen); but if it is a list, and everything after the hyphen is the list element, what is the list title?</p>

<p>using the idea mentioned in an answer, I tried to put the metadata block in a data-block beforehand:</p>

<pre><code>data "template_file" "map_roles" {
  template = &lt;&lt;EOF
- rolearn: ${var.arn}
  username: system:node:{{EC2PrivateDNSName}}
  groups:
    - system:bootstrappers
    - system:nodes
EOF

  vars {
    arn = "${var.kube-arn}"
  }
}

resource "kubernetes_config_map" "aws_auth" {
  metadata {
    name = "aws-auth"
    namespace = "kube-system"
  }
  data {
    mapRoles = "${data.template_file.map_roles.template}"
  } 
}
</code></pre>

<p>So when you have this in YAML:</p>

<pre><code>data:
  mapRoles: |
</code></pre>

<p>it means that everything after the <code>|</code> is a string that is the value of <code>mapRoles</code>. I'm not really sure that's what you want. If you want lists of lists you would want something like this:</p>

<pre><code>data:
  mapRoles:
  - rolearn: ${aws_iam_role.tf-eks-node.arn}
  - username: system:node:{{EC2PrivateDNSName}}
  - groups:
    - system:bootstrappers
    - system:nodes
</code></pre>

<p>This would translate into HCL to this:</p>

<pre><code>"data" = {
  "mapRoles" = {
    "rolearn" = "${aws_iam_role.tf-eks-node.arn}"
  }

  "mapRoles" = {
    "username" = "system:node:{{EC2PrivateDNSName}}"
  }

  "mapRoles" = {
    "groups" = ["system:bootstrappers", "system:nodes"]
  }
}
</code></pre>
