# Referencing a string array from data

**URL:** <https://discuss.hashicorp.com/t/referencing-a-string-array-from-data/47836>\
**Category:** CDK for Terraform\
**Created:** [December 9, 2022, 8:40pm UTC](https://discuss.hashicorp.com/t/referencing-a-string-array-from-data/47836 "2022-12-09T20:40:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![btomasini1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/btomasini1/32/32515_2.png) [@btomasini1](https://discuss.hashicorp.com/u/btomasini1)\
**Post date:** [December 9, 2022, 8:40pm UTC](https://discuss.hashicorp.com/t/referencing-a-string-array-from-data/47836/1 "2022-12-09T20:40:29Z")

</div>

I am trying to implement a cluster similar to this:

[https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks\_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster)

My difficulty comes in trying to create the IAM roles, specifically replicating this resource in CDK. Example below.

```nohighlight
resource "aws_iam_openid_connect_provider" "example" {
  client_id_list = ["sts.amazonaws.com"]
  thumbprint_list = data.tls_certificate.example.certificates[*].sha1_fingerprint
  url = data.tls_certificate.example.url
}

```

My code looks like this

```nohighlight
this.cluster = new aws.eksCluster.EksCluster(this, id, {
      name: id,
      roleArn: clusterRole.arn,
      vpcConfig: {
        subnetIds: props.subnetIds
      },
      dependsOn: [clusterRole, clusterRoleAttachment]
    })

    const tlsCert = new tls.dataTlsCertificate.DataTlsCertificate(this, "tls", {
      url: this.cluster.identity.get(0).oidc.get(0).issuer
    })

    const provider = new aws.iamOpenidConnectProvider.IamOpenidConnectProvider(this, "provider", {
      clientIdList: ["sts.amazonaws.com"],
      // HELP NEEEDED HERE
      thumbprintList: [], // ${data.tls_certificate.tls.certificates[*].sha1_fingerprint}
      url: tlsCert.url,
    })

```

What is the proper syntax to refer to a string array from a list of data elements?

---

<div class="post-metadata">

**Author:** ![btomasini1](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/btomasini1/32/32515_2.png) [@btomasini1](https://discuss.hashicorp.com/u/btomasini1)\
**Post date:** [December 12, 2022, 2:08am UTC](https://discuss.hashicorp.com/t/referencing-a-string-array-from-data/47836/2 "2022-12-12T02:08:25Z")

</div>

I solved this by doing the following. Let me know if there is a better way to handle this:

```auto
    const tlsCert = new tls.dataTlsCertificate.DataTlsCertificate(this, 'tls', {
      url: this.cluster.identity.get(0).oidc.get(0).issuer,
    });

    const provider = new aws.iamOpenidConnectProvider.IamOpenidConnectProvider(
      this,
      'provider',
      {
        clientIdList: ['sts.amazonaws.com'],
        thumbprintList: [], // ${data.tls_certificate.tls.certificates[*].sha1_fingerprint}
        url: tlsCert.url,
      }
    );

    provider.addOverride(
      'thumbprint_list',
      `\${data.tls_certificate.${tlsCert.friendlyUniqueId}.certificates[*].sha1_fingerprint}`
    );

```

---

<div class="post-metadata">

**Author:** ![jsteinich](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jsteinich/32/9502_2.png) [@jsteinich](https://discuss.hashicorp.com/u/jsteinich)\
**Post date:** [December 20, 2022, 3:57pm UTC](https://discuss.hashicorp.com/t/referencing-a-string-array-from-data/47836/3 "2022-12-20T15:57:37Z")

</div>

Yeah, that’s pretty much the only way right now. Feel free to give [Support accessing resources created by an iterator · Issue #2024 · hashicorp/terraform-cdk · GitHub](https://github.com/hashicorp/terraform-cdk/issues/2024) a thumbsup for improving the functionality.
