Skip to content

Commit

Permalink
Merge pull request #4424 from terraform-providers/b/container_registr…
Browse files Browse the repository at this point in the history
…y-check

azurerm_container_registry - Checks if name is available on `create`
  • Loading branch information
tombuildsstuff authored Sep 26, 2019
2 parents 2f5a008 + 02d0c52 commit b5941cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions azurerm/resource_arm_container_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{}
}
}

availabilityRequest := containerregistry.RegistryNameCheckRequest{
Name: utils.String(name),
Type: utils.String("Microsoft.ContainerRegistry/registries"),
}
available, err := client.CheckNameAvailability(ctx, availabilityRequest)
if err != nil {
return fmt.Errorf("Error checking if the name %q was available: %+v", name, err)
}

if !*available.NameAvailable {
return fmt.Errorf("The name %q used for the Container Registry needs to be globally unique and isn't available: %s", name, *available.Message)
}

location := azure.NormalizeLocation(d.Get("location").(string))
sku := d.Get("sku").(string)
adminUserEnabled := d.Get("admin_enabled").(bool)
Expand Down

0 comments on commit b5941cb

Please sign in to comment.