I am setting up a resource in AWS which is to be accessed from other AWS accounts. The list of accounts that can access this resource is different based on the deployment (QA, Pre-Prod, PROD, etc.)

The list of accounts looks like this.

```
variable "my_list" {
    default = ["123456789", "111222333"]
}

```

Following is what I am expecting in the trust policy of the role.

```
 "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789:root",
        "AWS": "arn:aws:iam::111222333:root"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

```

I have tried to use count in Terraform on the `aws_iam_role` resource, but as expected, the count is creating multiple IAM roles.

Is there another way to achieve this?