Skip to content

Commit

Permalink
Merge pull request #7189 from terraform-providers/b/cosmosdb-checknam…
Browse files Browse the repository at this point in the history
…e-workaround

re-added 500 Response workaround for CosmosDB CheckNameExists bug
  • Loading branch information
jackofallops committed Jun 3, 2020
2 parents 077cc4e + 8f8d86d commit 7e6bd92
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions azurerm/internal/services/cosmos/cosmosdb_account_resource.go
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"net/http"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -307,13 +308,15 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{})

r, err := client.CheckNameExists(ctx, name)
if err != nil {
return fmt.Errorf("Error checking if CosmosDB Account %q already exists (Resource Group %q): %+v", name, resourceGroup, err)
}

if !utils.ResponseWasNotFound(r) {
return fmt.Errorf("CosmosDB Account %s already exists, please import the resource via terraform import", name)
// todo remove when https://github.com/Azure/azure-sdk-for-go/issues/9891 is fixed
if !utils.ResponseWasStatusCode(r, http.StatusInternalServerError) {
return fmt.Errorf("Error checking if CosmosDB Account %q already exists (Resource Group %q): %+v", name, resourceGroup, err)
}
} else {
if !utils.ResponseWasNotFound(r) {
return fmt.Errorf("CosmosDB Account %s already exists, please import the resource via terraform import", name)
}
}

geoLocations, err := expandAzureRmCosmosDBAccountGeoLocations(name, d)
if err != nil {
return fmt.Errorf("Error expanding CosmosDB Account %q (Resource Group %q) geo locations: %+v", name, resourceGroup, err)
Expand Down

0 comments on commit 7e6bd92

Please sign in to comment.