<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>The first step is to find a Terraform resource type that matches what you're looking for. The <a href="https://www.terraform.io/docs/providers/kubernetes/index.html" rel="nofollow noreferrer">Terraform Kubernetes provider</a> has historically been a little sparse but now does include basic objects like Deployments and <a href="https://www.terraform.io/docs/providers/kubernetes/r/config_map.html" rel="nofollow noreferrer">ConfigMaps</a>.  (Not DaemonSets, though.)</p>

<p>As @Rico notes in their answer, the <code>data:</code> of a ConfigMap is just a map from string name to string value, and your example uses a YAML multi-line string syntax.  HCL has a different syntax that looks like shell here-documents.  To do the interpolation you also need to feed it through a <a href="https://www.terraform.io/docs/providers/template/d/file.html" rel="nofollow noreferrer">template</a>.  So you should be able to translate this to:</p>

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

  vars {
    arn = ${aws_iam_role.tf-eks-node.arn}
  }
}

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