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
230 stars 167 forks source link

[Bug]: mongodbatlas_network_peering returning incorrect outputs after update to 1.16.1 #2308

Closed a88zach closed 1 month ago

a88zach commented 1 month ago

Is there an existing issue for this?

Provider Version

1.16.1

Terraform Version

1.8.4

Terraform Edition

Terraform Cloud

Current Behavior

After updating to version 1.16.1, the mongodbatlas_network_peering resource is returning incorrect outputs for a gcp peering connection.

Before:

output "atlas_vpc_project_id" {
  value = mongodbatlas_network_peering.gcp_peering.atlas_gcp_project_id # p-cwoo1hny1spwjsrffawz****
}

output "atlas_vpc_name" {
  value = mongodbatlas_network_peering.gcp_peering.atlas_vpc_name # nt-6579b219eabfad1605b3e2dc-qetx****
}

After:

output "atlas_vpc_project_id" {
  value = mongodbatlas_network_peering.gcp_peering.atlas_gcp_project_id # my-project-id
}

output "atlas_vpc_name" {
  value = mongodbatlas_network_peering.gcp_peering.atlas_vpc_name # my-network-name
}

Terraform configuration to reproduce the issue

locals {
  provider_name = mongodbatlas_advanced_cluster.cluster_rtd.replication_specs.0.region_configs.0.provider_name
  region_name   = mongodbatlas_advanced_cluster.cluster_rtd.replication_specs.0.region_configs.0.region_name
}

locals {
  container_id = "${local.provider_name}:${local.region_name}"
}

resource "mongodbatlas_network_peering" "gcp_peering" {
  project_id       = mongodbatlas_project.main_project.id
  atlas_cidr_block = "192.168.0.0/16"

  container_id   = mongodbatlas_advanced_cluster.cluster_rtd.replication_specs.0.container_id[local.container_id]
  provider_name  = "GCP"
  gcp_project_id = var.gcp_project_id
  network_name   = var.gcp_serverless_network_name
}

resource "google_compute_network_peering" "atlas_peering" {
  name         = "atlas-peering"
  network      = google_compute_network.serverless_network.self_link
  peer_network = "https://www.googleapis.com/compute/v1/projects/${mongodbatlas_network_peering.gcp_peering.atlas_gcp_project_id}/global/networks/${mongodbatlas_network_peering.gcp_peering.atlas_vpc_name}"
}

Steps To Reproduce

Set up a peering connection for GCP following the documentation. The peer_network for the google_compute_network_peering resource will be incorrect as the atlas_gcp_project_id will be the customer's project id and the atlas_vpc_name will be the customers network name

Logs

update
peer_network :
"https://www.googleapis.com/compute/v1/projects/p-cwoo1hny1spwjsrffawz****/global/networks/nt-6579b219eabfad1605b3e2dc-qetx****"
change to
"https://www.googleapis.com/compute/v1/projects/my-project-name/global/networks/my-network-name"
Forces replacement

Code of Conduct

github-actions[bot] commented 1 month ago

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

The ticket CLOUDP-250959 was created for internal tracking.

AgustinBettati commented 1 month ago

Hello @a88zach. Thank you for bringing this up on a short notice, I was able to reproduce the issue and we are looking into a fix. I will keep you updated.

AgustinBettati commented 1 month ago

Hi @a88zach, the fix associated to this issue has been merged and will be included in the next release. Thank you again for bringing this up.

AgustinBettati commented 1 month ago

@a88zach The new 1.16.2 release includes this fix.