Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_mongo_cluster resource does not accept source_server_id when source and replica are created in one run #28255

Open
1 task done
fdammeke opened this issue Dec 11, 2024 · 0 comments · May be fixed by #28269
Open
1 task done

Comments

@fdammeke
Copy link

fdammeke commented Dec 11, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.3

AzureRM Provider Version

4.13.0

Affected Resource(s)/Data Source(s)

azurerm_mongo_cluster

Terraform Configuration Files

resource "azurerm_mongo_cluster" "primary" {
  name                   = var.name
  resource_group_name    = var.resource_group_name
  location               = var.location
  create_mode            = var.create_mode
  administrator_username = var.administrator_username
  administrator_password = var.administrator_password
  shard_count            = var.shard_count
  compute_tier           = var.compute_tier
  high_availability_mode = var.high_availability_mode
  storage_size_in_gb     = var.storage_size_in_gb
  public_network_access  = var.public_network_access
  version                = var.mongo_version
  preview_features       = var.preview_features
}

resource "azurerm_mongo_cluster" "replica" {
  count               = var.replica_enabled == true ? 1 : 0
  name                = var.name
  resource_group_name = var.resource_group_name
  location            = var.replica_location
  create_mode         = "GeoReplica"
  source_server_id    = azurerm_mongo_cluster.primary.id
  source_location     = azurerm_mongo_cluster.primary.location

  lifecycle {
    ignore_changes = [administrator_username, high_availability_mode, preview_features, shard_count, storage_size_in_gb, compute_tier, version]
  }

  depends_on = [azurerm_mongo_cluster.cluster]
}

Debug Output/Panic Output

│ Error: `source_server_id` is required when `create_mode` is `GeoReplica`
│
│   with module.azure_mongodb_cluster["mongo-replica-01"].azurerm_mongo_cluster.replica[0],
│   on ../../modules/terraform-modules-azure/modules/azure-mongodb-cluster/resource.tf line 28, in resource "azurerm_mongo_cluster" "replica":
│   28: resource "azurerm_mongo_cluster" "replica" {

Expected Behaviour

The replica mongodb_cluster should be created after the primary instance is created.

Actual Behaviour

Create fails because the primary cluster id can not be fetched from the state.

Steps to Reproduce

Run the provided code using terraform apply

Important Factoids

No response

References

The same state check for CreateModeGeoReplica is done as in an existing other issue:
https://github.com/hashicorp/terraform-provider-azurerm/pull/28215/files#diff-c0c03a38fa70112165c0529e41c65e8112e6112b29144829288f5d783891a14bL515

@fdammeke fdammeke changed the title azurerm_mongo_cluster resource does not accept source_server_id when source and replica are created in one run azurerm_mongo_cluster resource does not accept source_server_id when source and replica are created in one run Dec 11, 2024
@rcskosir rcskosir added the bug label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants