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

r/key_vault_certificate: exposing the certificate data field #1200

Merged
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
9 changes: 9 additions & 0 deletions azurerm/resource_arm_key_vault_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ func resourceArmKeyVaultCertificate() *schema.Resource {
Computed: true,
},

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

"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -339,6 +344,10 @@ func resourceArmKeyVaultCertificateRead(d *schema.ResourceData, meta interface{}
// Computed
d.Set("version", id.Version)
d.Set("secret_id", cert.Sid)

if contents := cert.Cer; contents != nil {
d.Set("certificate_data", string(*contents))
}
flattenAndSetTags(d, cert.Tags)

return nil
Expand Down
3 changes: 3 additions & 0 deletions azurerm/resource_arm_key_vault_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccAzureRMKeyVaultCertificate_basicImportPFX(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKeyVaultCertificateExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "certificate_data"),
),
},
},
Expand All @@ -45,6 +46,7 @@ func TestAccAzureRMKeyVaultCertificate_basicGenerate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKeyVaultCertificateExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "secret_id"),
resource.TestCheckResourceAttrSet(resourceName, "certificate_data"),
),
},
},
Expand All @@ -65,6 +67,7 @@ func TestAccAzureRMKeyVaultCertificate_basicGenerateTags(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKeyVaultCertificateExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "certificate_data"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.hello", "world"),
),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/key_vault_certificate.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ The following attributes are exported:
* `id` - The Key Vault Certificate ID.
* `secret_id` - The ID of the associated Key Vault Secret.
* `version` - The current version of the Key Vault Certificate.
* `certificate_data` - The raw Key Vault Certificate


## Import
Expand Down