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

re-added 500 Response workaround for CosmosDB CheckNameExists bug #7189

Merged
merged 1 commit into from Jun 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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