Skip to content

Commit

Permalink
Merge pull request #5488 from saravanan30erd/issue-5160
Browse files Browse the repository at this point in the history
Issue #5160 arn as an attribute for aws_secretsmanager_secret_version
  • Loading branch information
bflad committed Aug 9, 2018
2 parents 5963b1f + 45ba37c commit f972c08
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions aws/data_source_aws_secretsmanager_secret_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func dataSourceAwsSecretsManagerSecretVersion() *schema.Resource {
Read: dataSourceAwsSecretsManagerSecretVersionRead,

Schema: map[string]*schema.Schema{
"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"secret_id": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -78,6 +82,7 @@ func dataSourceAwsSecretsManagerSecretVersionRead(d *schema.ResourceData, meta i
d.Set("secret_id", secretID)
d.Set("secret_string", output.SecretString)
d.Set("version_id", output.VersionId)
d.Set("arn", output.ARN)

if err := d.Set("version_stages", flattenStringList(output.VersionStages)); err != nil {
return fmt.Errorf("error setting version_stages: %s", err)
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_secretsmanager_secret_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func resourceAwsSecretsManagerSecretVersion() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"secret_id": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -102,6 +106,7 @@ func resourceAwsSecretsManagerSecretVersionRead(d *schema.ResourceData, meta int
d.Set("secret_id", secretID)
d.Set("secret_string", output.SecretString)
d.Set("version_id", output.VersionId)
d.Set("arn", output.ARN)

if err := d.Set("version_stages", flattenStringList(output.VersionStages)); err != nil {
return fmt.Errorf("error setting version_stages: %s", err)
Expand Down
3 changes: 3 additions & 0 deletions aws/resource_aws_secretsmanager_secret_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -29,6 +30,8 @@ func TestAccAwsSecretsManagerSecretVersion_Basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "version_id"),
resource.TestCheckResourceAttr(resourceName, "version_stages.#", "1"),
resource.TestCheckResourceAttr(resourceName, "version_stages.3070137", "AWSCURRENT"),
resource.TestMatchResourceAttr(resourceName, "arn",
regexp.MustCompile(`^arn:[\w-]+:secretsmanager:[^:]+:\d{12}:secret:.+$`)),
),
},
{
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/secretsmanager_secret_version.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data "aws_secretsmanager_secret_version" "by-version-stage" {

## Attributes Reference

* `arn` - The ARN of the secret.
* `id` - The unique identifier of this version of the secret.
* `secret_string` - The decrypted part of the protected secret information that was originally provided as a string.
* `version_id` - The unique identifier of this version of the secret.
3 changes: 2 additions & 1 deletion website/docs/r/secretsmanager_secret_version.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ The following arguments are supported:

## Attribute Reference

* `id` - A pipe delimited combination of secret ID and version ID
* `arn` - The ARN of the secret.
* `id` - A pipe delimited combination of secret ID and version ID.
* `version_id` - The unique identifier of the version of the secret.

## Import
Expand Down

0 comments on commit f972c08

Please sign in to comment.