mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
238 stars 167 forks source link

GCP Peering endless terraform apply #41

Closed rrondeau closed 4 years ago

rrondeau commented 4 years ago

Hi

I cant get this provider to work with peering. I start with an empty project, no container.

This is my code :

data "mongodbatlas_project" "test" {
  name = "test-project"
}

data "google_compute_network" "network" {
  project = var.project
  name    = var.network
}

resource "mongodbatlas_network_container" "test" {
  project_id       = data.mongodbatlas_project.test.id
  atlas_cidr_block = "10.1.0.0/18"
  provider_name    = "GCP"
}

resource "mongodbatlas_network_peering" "test" {
  project_id     = data.mongodbatlas_project.test.id
  container_id   = mongodbatlas_network_container.test.container_id
  provider_name  = "GCP"
  network_name   = data.google_compute_network.network.name
  gcp_project_id = var.project
}

resource "google_compute_network_peering" "atlas_peer" {
  name         = "atlas-peering"
  network      = data.google_compute_network.network.self_link
  peer_network = "https://www.googleapis.com/compute/v1/projects/${mongodbatlas_network_container.test.gcp_project_id}/global/networks/${mongodbatlas_network_container.test.network_name}"
}

The thing is mongodbatlas_network_peering wait for the peering to be up but on the other end mongodbatlas_network_container does not return the values to the google_compute_network_peering resource.

What did i do wrong ?

rrondeau commented 4 years ago

The peering is stuck on WAITING_FOR_USER status. It appears that this status is considered like pending in the source : https://github.com/terraform-providers/terraform-provider-mongodbatlas/blob/master/mongodbatlas/resource_mongodbatlas_network_peering.go#L247

rrondeau commented 4 years ago

I manage to get it working with this steps :

This is of course a temporary solution, can you point me the right solution/example ?

themantissa commented 4 years ago

@rrondeau thank you, we are working on this issue. @PacoDw - fyi.

PacoDw commented 4 years ago

Thank you so much for your review! it's so helpful 👍

PacoDw commented 4 years ago

Hello @rrondeau we have made the fix on the PR #43, could you check the example configuration on there and test on the Network peering branch?

If you have another comment plz let us know, thanks!

rrondeau commented 4 years ago

Hello @PacoDw , it works like a charm ! Thank you !