Skip to content

Commit

Permalink
azurerm_keyvault_secret: support versionless_id attribute #10738
Browse files Browse the repository at this point in the history
  • Loading branch information
favoretti authored Feb 26, 2021
1 parent 1261248 commit ac19140
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault"
Expand Down Expand Up @@ -81,6 +82,11 @@ func resourceKeyVaultSecret() *schema.Resource {
Computed: true,
},

"versionless_id": {
Type: schema.TypeString,
Computed: true,
},

"tags": tags.Schema(),
},
}
Expand Down Expand Up @@ -336,6 +342,7 @@ func resourceKeyVaultSecretRead(d *schema.ResourceData, meta interface{}) error
d.Set("value", resp.Value)
d.Set("version", respID.Version)
d.Set("content_type", resp.ContentType)
d.Set("versionless_id", fmt.Sprintf("%s/%s/%s", strings.TrimSuffix(id.KeyVaultBaseUrl, "/"), id.NestedItemType, id.Name))

if attributes := resp.Attributes; attributes != nil {
if v := attributes.NotBefore; v != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestAccKeyVaultSecret_complete(t *testing.T) {
check.That(data.ResourceName).Key("expiration_date").HasValue("2020-01-01T01:02:03Z"),
check.That(data.ResourceName).Key("tags.%").HasValue("1"),
check.That(data.ResourceName).Key("tags.hello").HasValue("world"),
check.That(data.ResourceName).Key("versionless_id").HasValue(fmt.Sprintf("https://acctestkv-%s.vault.azure.net/secrets/secret-%s", data.RandomString, data.RandomString)),
),
},
data.ImportStep(),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/key_vault_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The following attributes are exported:

* `id` - The Key Vault Secret ID.
* `version` - The current version of the Key Vault Secret.
* `versionless_id` - The Base ID of the Key Vault Secret.

## Timeouts

Expand Down

0 comments on commit ac19140

Please sign in to comment.