0

I have the following terraform code

resource "azurerm_app_service_certificate" "cert" {
  for_each = local.certificates_locations

  name                = each.value.certificate_name
  resource_group_name = var.regional_web_rg[each.value.location].name
  location            = each.value.location
  key_vault_secret_id = data.azurerm_key_vault_secret.cert[each.value.certificate_name].id
  lifecycle {
    ignore_changes  = [tags, ]
  }
}

There are multiple certificates that I am trying to provision into multiple locations. This code fails sporadically with the following message.

Error: creating/updating App Service Certificate "wildcard-dayforce-com" 
(Resource Group "appXXX-dfhub-prod2-web-eastus2"):
web.CertificatesClient#CreateOrUpdate:
Failure responding to request: StatusCode=409 -- 
Original Error: autorest/azure:
Service returned an error.
Status=409 Code="Conflict" Message="Cannot modify this webspace because another operation is in progress.
Details: Id: 6ad40ea3-aae5-49e7-b9e6-971b02c1af17, OperationName: Create, CreatedTime: 4/19/2022 2:26:48 AM, RequestId: 9ea28046-c20d-4c4c-8f54-51ca564b8ce5, EntityType: 2"
Details=[{"Message":"Cannot modify this webspace because another operation is in progress. Details: Id: 6ad40ea3-aae5-49e7-b9e6-971b02c1af17, OperationName: Create, CreatedTime: 4/19/2022 2:26:48 AM, RequestId: 9ea28046-c20d-4c4c-8f54-51ca564b8ce5, EntityType: 2"},{"Code":"Conflict"},{"ErrorEntity":{"Code":"Conflict","ExtendedCode":"59202","Message":"Cannot modify this webspace because another operation is in progress. Details: Id: 6ad40ea3-aae5-49e7-b9e6-971b02c1af17, OperationName: Create, CreatedTime: 4/19/2022 2:26:48 AM, RequestId: 9ea28046-c20d-4c4c-8f54-51ca564b8ce5, EntityType: 2","MessageTemplate":"Cannot modify this webspace because another operation is in progress. Details: {0}","Parameters":["Id: 6ad40ea3-aae5-49e7-b9e6-971b02c1af17, OperationName: Create, CreatedTime: 4/19/2022 2:26:48 AM, RequestId: 9ea28046-c20d-4c4c-8f54-51ca564b8ce5, EntityType: 2"]}}]

Is there a way to work this issue around, maybe it's possible to retry the request in terraform so it will be able to accomplish it on additional attempt. Any help would be gratefully appriciated.

EDIT 1 Here is the local.ceritifcates_locations outputted as a json

{
  + wildcard-np-dayforce-com-centralus    = {
      + certificate_name = "wildcard-np-dayforce-com"
      + location         = "centralus"
    }
  + wildcard-np-dayforce-com-eastus2      = {
      + certificate_name = "wildcard-np-dayforce-com"
      + location         = "eastus2"
    }
  + wildcard-np-dayforcehcm-com-centralus = {
      + certificate_name = "wildcard-np-dayforcehcm-com"
      + location         = "centralus"
    }
  + wildcard-np-dayforcehcm-com-eastus2   = {
      + certificate_name = "wildcard-np-dayforcehcm-com"
      + location         = "eastus2"
    }
} 
Alexey Auslender
  • 402
  • 5
  • 18

0 Answers0