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

key_vault_secret: Set value of recoverd key vault secret #10920

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ func resourceKeyVaultSecretCreate(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error waiting for Key Vault Secret %q to become available: %s", name, err)
}
log.Printf("[DEBUG] Secret %q recovered with ID: %q", name, *recoveredSecret.ID)

_, err := client.SetSecret(ctx, *keyVaultBaseUrl, name, parameters)
if err != nil {
return err
}
}
} else {
// If the error response was anything else, or `recover_soft_deleted_key_vaults` is `false` just return the error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,22 @@ func TestAccKeyVaultSecret_recovery(t *testing.T) {

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.softDeleteRecovery(data, false),
Config: r.softDeleteRecovery(data, false, "first"),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("value").HasValue("rick-and-morty"),
check.That(data.ResourceName).Key("value").HasValue("first"),
),
},
{
Config: r.softDeleteRecovery(data, false),
Config: r.softDeleteRecovery(data, false, "first"),
Destroy: true,
},
{
// purge true here to make sure when we end the test there's no soft-deleted items left behind
Config: r.softDeleteRecovery(data, true),
Config: r.softDeleteRecovery(data, true, "second"),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("value").HasValue("rick-and-morty"),
check.That(data.ResourceName).Key("value").HasValue("second"),
),
},
})
Expand Down Expand Up @@ -395,7 +395,7 @@ resource "azurerm_key_vault_secret" "test" {
`, r.template(data), data.RandomString)
}

func (r KeyVaultSecretResource) softDeleteRecovery(data acceptance.TestData, purge bool) string {
func (r KeyVaultSecretResource) softDeleteRecovery(data acceptance.TestData, purge bool, value string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {
Expand All @@ -410,10 +410,10 @@ provider "azurerm" {

resource "azurerm_key_vault_secret" "test" {
name = "secret-%s"
value = "rick-and-morty"
value = "%s"
key_vault_id = azurerm_key_vault.test.id
}
`, purge, r.template(data), data.RandomString)
`, purge, r.template(data), data.RandomString, value)
}

func (KeyVaultSecretResource) withExternalAccessPolicy(data acceptance.TestData) string {
Expand Down