mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-05 21:53:04 -06:00
providers/azurerm: attempt to read storage account ID if cancelled
This commit is contained in:
parent
8dafcb36fd
commit
ccb972ae50
@ -141,23 +141,34 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e
|
|||||||
|
|
||||||
// Check the result of the wrapped function. I put this into a select
|
// Check the result of the wrapped function. I put this into a select
|
||||||
// since we will likely also want to introduce a time-based timeout.
|
// since we will likely also want to introduce a time-based timeout.
|
||||||
var err error
|
var createErr error
|
||||||
select {
|
select {
|
||||||
case err = <-wrap.ErrCh:
|
case createErr = <-wrap.ErrCh:
|
||||||
// Successfully ran (but perhaps not successfully completed)
|
// Successfully ran (but perhaps not successfully completed)
|
||||||
// the function.
|
// the function.
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf(
|
|
||||||
"Error creating Azure Storage Account '%s': %s",
|
|
||||||
storageAccountName, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The only way to get the ID back apparently is to read the resource again
|
// The only way to get the ID back apparently is to read the resource again
|
||||||
read, err := storageClient.GetProperties(resourceGroupName, storageAccountName)
|
read, err := storageClient.GetProperties(resourceGroupName, storageAccountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the ID right away if we have one
|
||||||
|
if read.ID != nil {
|
||||||
|
log.Printf("[INFO] storage account %q ID: %q", storageAccountName, *read.ID)
|
||||||
|
d.SetId(*read.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we had a create error earlier then we return with that error now.
|
||||||
|
// We do this later here so that we can grab the ID above is possible.
|
||||||
|
if createErr != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Error creating Azure Storage Account '%s': %s",
|
||||||
|
storageAccountName, createErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we got no ID then the resource group doesn't yet exist
|
||||||
if read.ID == nil {
|
if read.ID == nil {
|
||||||
return fmt.Errorf("Cannot read Storage Account %s (resource group %s) ID",
|
return fmt.Errorf("Cannot read Storage Account %s (resource group %s) ID",
|
||||||
storageAccountName, resourceGroupName)
|
storageAccountName, resourceGroupName)
|
||||||
@ -175,8 +186,6 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e
|
|||||||
return fmt.Errorf("Error waiting for Storage Account (%s) to become available: %s", storageAccountName, err)
|
return fmt.Errorf("Error waiting for Storage Account (%s) to become available: %s", storageAccountName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(*read.ID)
|
|
||||||
|
|
||||||
return resourceArmStorageAccountRead(d, meta)
|
return resourceArmStorageAccountRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user