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

Issue #5160 arn as an attribute for aws_secretsmanager_secret_version #5488

Merged
merged 4 commits into from Aug 9, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions aws/data_source_aws_secretsmanager_secret_version.go
Expand Up @@ -14,6 +14,10 @@ func dataSourceAwsSecretsManagerSecretVersion() *schema.Resource {
Read: dataSourceAwsSecretsManagerSecretVersionRead,

Schema: map[string]*schema.Schema{
"arn": &schema.Schema{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the &schema.Schema here is extraneous since Go 1.7 as its previously defined by the map[string]*schema.Schema above

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
Expand Up @@ -21,6 +21,10 @@ func resourceAwsSecretsManagerSecretVersion() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"arn": &schema.Schema{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the &schema.Schema here is extraneous since Go 1.7 as its previously defined by the map[string]*schema.Schema above

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
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
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
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