terraform-provider-mongodbatlas: Terraform: Unable to fetch connection strings when using 'data' resource for existing cluster

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.14.6
+ provider registry.terraform.io/hashicorp/aws v3.31.0
+ provider registry.terraform.io/terraform-providers/mongodbatlas v0.8.2

Terraform Configuration File

  • I have followed the aws-privatelink example here aws-privatelink the only difference is that I’m setting it on an existing cluster, so sharing the code for that

altas_cluster.tf

data "mongodbatlas_cluster" "cluster-atlas" {
project_id                   = var.atlasprojectid
name                         = "mongoatlas-cluster-xxxxxxx"
depends_on                   = [time_sleep.wait_300_seconds]
}
output "atlasclusterstring" {
     value = data.mongodbatlas_cluster.cluster-atlas.connection_strings

}
output "plstring" {
value = lookup(data.mongodbatlas_cluster.cluster- 
atlas.connection_strings[0].aws_private_link, aws_vpc_endpoint.ptfe_service.id)
}

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

atlasclusterstring = [
  {
    "aws_private_link" = {
      "vpce-0ebb76559e8affc96" = "mongodb://pl-0-us-east-1.za3fb.mongodb.net:1024,pl-0-us-east-1.za3fb.mongodb.net:1025,pl-0-us-east-1.za3fb.mongodb.net:1026/?ssl=true&authSource=admin&replicaSet=atlas-d177ke-shard-0"
    }
    "aws_private_link_srv" = {
      "vpce-0ebb76559e8affc96" = "mongodb+srv://cluster-atlas-pl-0.za3fb.mongodb.net"
    }
    "private" = ""
    "private_srv" = ""
    "standard" = "mongodb://cluster-atlas-shard-00-00.za3fb.mongodb.net:27017,cluster-atlas-shard-00-01.za3fb.mongodb.net:27017,cluster-atlas-shard-00-02.za3fb.mongodb.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-d177ke-shard-0"
    "standard_srv" = "mongodb+srv://cluster-atlas.za3fb.mongodb.net"
  },
]

Actual Behavior

data.mongodbatlas_cluster.cluster-atlas.connection_strings[0].aws_private_link is empty map of string

Additional Context

I’m creating privatelink on an existing cluster and according to the example I need to pass in cluster name in the lookup function to fetch the pl_string so, for that purpose, I’m using “data” resource of terraform to get cluster information and then passing it to lookup function

References

aws-atlas-privatelink

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18

Most upvoted comments

Just looked and we are waiting for available. I think what might be happening is the cluster resource is not being updated with the new connection string in the same apply - which is why the 2nd apply works. I’ll check with our developers to verify my assumption here.

@zf-tomdesmet this will be in our next release, 1.0.0. We are working to finish up the required items and hope to release in the near term. Thanks!

@srashish we are investigating a way to address this timing issue and hope to have an improvement for the next provider version. Unknown on ETA at this time.