Skip to content

azurerm_search_shared_private_link_service failed to create multiple shared private links. #28601

@lgong-rms

Description

@lgong-rms

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.6.2

AzureRM Provider Version

4.16.0

Affected Resource(s)/Data Source(s)

azurerm_search_shared_private_link_service

Terraform Configuration Files

# providers.tf
terraform {
  required_version = ">=1.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~>4.16.0"
    }
    random = {
      source  = "hashicorp/random"
      version = "~>3.6.3"
    }
  }
}
provider "azurerm" {
  features {}
}

# variables.tf
variable "resource_group_location" {
  type        = string
  description = "Location for all resources."
  default     = "eastus"
}

variable "resource_group_name_prefix" {
  type        = string
  description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
  default     = "rg"
}

variable "sku" {
  description = "The pricing tier of the search service you want to create (for example, basic or standard)."
  default     = "standard"
  type        = string
  validation {
    condition     = contains(["free", "basic", "standard", "standard2", "standard3", "storage_optimized_l1", "storage_optimized_l2"], var.sku)
    error_message = "The sku must be one of the following values: free, basic, standard, standard2, standard3, storage_optimized_l1, storage_optimized_l2."
  }
}

variable "replica_count" {
  type        = number
  description = "Replicas distribute search workloads across the service. You need at least two replicas to support high availability of query workloads (not applicable to the free tier)."
  default     = 1
  validation {
    condition     = var.replica_count >= 1 && var.replica_count <= 12
    error_message = "The replica_count must be between 1 and 12."
  }
}

variable "partition_count" {
  type        = number
  description = "Partitions allow for scaling of document count as well as faster indexing by sharding your index over multiple search units."
  default     = 1
  validation {
    condition     = contains([1, 2, 3, 4, 6, 12], var.partition_count)
    error_message = "The partition_count must be one of the following values: 1, 2, 3, 4, 6, 12."
  }
}

# main.tf
resource "random_pet" "rg_name" {
  prefix = var.resource_group_name_prefix
}

resource "azurerm_resource_group" "rg" {
  name     = random_pet.rg_name.id
  location = var.resource_group_location
}

resource "random_string" "azurerm_search_service_name" {
  length  = 25
  upper   = false
  numeric = false
  special = false
}

resource "azurerm_search_service" "search" {
  name                = random_string.azurerm_search_service_name.result
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  sku                 = var.sku
  replica_count       = var.replica_count
  partition_count     = var.partition_count
}

resource "azurerm_storage_account" "test" {
  count                    = 2

  name                     = "lgongteststorage${count.index}"
  resource_group_name      = azurerm_resource_group.rg.name
  location                 = azurerm_resource_group.rg.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_search_shared_private_link_service" "test" {
  count              = 2

  name               = "example-spl${count.index}"
  search_service_id  = azurerm_search_service.search.id
  subresource_name   = "blob"
  target_resource_id = azurerm_storage_account.test[count.index].id
  request_message    = "please approve"
}

# outputs.tf
output "resource_group_name" {
  value = azurerm_resource_group.rg.name
}

output "azurerm_search_service_name" {
  value = azurerm_search_service.search.name
}

Debug Output/Panic Output

│ Error: creating/ updating Shared Private Link Resource (Subscription: "<redacted>"
│ Resource Group Name: "rg-ready-cub"
│ Search Service Name: "afebkchszskjkhhmsiqnsyuwb"
│ Shared Private Link Resource Name: "example-spl1"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: Unknown: {"error":{"code":"","message":"There was a conflicting update. No change was made to the resource from this request."}} RequestId: 7bedc35d-d51e-474b-84d6-b397ffe2915d
│
│   with azurerm_search_shared_private_link_service.test[1],
│   on main.tf line 36, in resource "azurerm_search_shared_private_link_service" "test":
│   36: resource "azurerm_search_shared_private_link_service" "test" {
│
│ creating/ updating Shared Private Link Resource (Subscription: "<redacted>"
│ Resource Group Name: "rg-ready-cub"
│ Search Service Name: "afebkchszskjkhhmsiqnsyuwb"
│ Shared Private Link Resource Name: "example-spl1"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: Unknown:  
│ {"error":{"code":"","message":"There was a conflicting update. No change was made to the resource from this request."}} RequestId:        
│ 7bedc35d-d51e-474b-84d6-b397ffe2915d

Expected Behaviour

multiple shared private links should be created.

Actual Behaviour

failed to create multiple shared private links

Steps to Reproduce

  1. terraform init
  2. terraform apply --auto-approve

Important Factoids

no

References

no

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions