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

azurerm_key_vault_managed_storage_account - fix TestAccKeyVaultManagedStorageAccount_* #23022

Merged
merged 5 commits into from Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
Expand Up @@ -169,7 +169,7 @@ func resourceKeyVaultManagedStorageAccountCreateUpdate(d *pluginsdk.ResourceData
return fmt.Errorf("cannot read Managed Storage Account ID %q (Key Vault %q)", name, *keyVaultId)
}

storageId, err := commonids.ParseStorageAccountID(*read.ID)
storageId, err := keyVaultParse.ParseOptionallyVersionedNestedItemID(*read.ID)
if err != nil {
return err
}
Expand Down
Expand Up @@ -180,7 +180,12 @@ func resourceKeyVaultManagedStorageAccountSasTokenDefinitionCreateUpdate(d *plug
return fmt.Errorf("cannot read Managed Storage Account Sas Definition %q (Storage Account %q, Key Vault %q)", name, storageAccount.Name, *keyVaultId)
}

d.SetId(*read.ID)
sasId, err := parse.SasDefinitionID(*read.ID)
if err != nil {
return err
}

d.SetId(sasId.ID())

return resourceKeyVaultManagedStorageAccountSasTokenDefinitionRead(d, meta)
}
Expand Down
5 changes: 5 additions & 0 deletions internal/services/keyvault/parse/sas_definition.go
Expand Up @@ -15,6 +15,11 @@ type SasDefinitionId struct {
Name string
}

func (i SasDefinitionId) ID() string {
fmtString := "%sstorage/%s/sas/%s"
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Sprintf(fmtString, i.KeyVaultBaseUrl, i.StorageAccountName, i.Name)
}

func SasDefinitionID(id string) (*SasDefinitionId, error) {
// example: https://example-keyvault.vault.azure.net/storage/exampleStorageAcc01/sas/exampleSasDefinition01
idURL, err := url.ParseRequestURI(id)
Expand Down