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

aws secret manager datasource with Created date #35117

Closed
Closed
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
10 changes: 10 additions & 0 deletions internal/service/secretsmanager/secret_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func DataSourceSecret() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
"last_changed_date": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -99,6 +107,8 @@ func dataSourceSecretRead(ctx context.Context, d *schema.ResourceData, meta inte
d.Set("kms_key_id", output.KmsKeyId)
d.Set("name", output.Name)
d.Set("policy", "")
d.Set("created_date", aws.String(output.CreatedDate.Format("2006-01-02T15:04:05Z07:00")))
d.Set("last_changed_date", aws.String(output.LastChangedDate.Format("2006-01-02T15:04:05Z07:00")))

pIn := &secretsmanager.GetResourcePolicyInput{
SecretId: aws.String(d.Id()),
Expand Down
2 changes: 2 additions & 0 deletions internal/service/secretsmanager/secret_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ func testAccSecretCheckDataSource(datasourceName, resourceName string) resource.
"name",
"policy",
"tags.#",
"created_date",
"last_changed_date",
}

for _, attrName := range attrNames {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func DataSourceSecretVersion() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -99,6 +103,7 @@ func dataSourceSecretVersionRead(ctx context.Context, d *schema.ResourceData, me
d.Set("version_id", output.VersionId)
d.Set("secret_binary", string(output.SecretBinary))
d.Set("arn", output.ARN)
d.Set("created_date", aws.String(output.CreatedDate.Format("2006-01-02T15:04:05Z07:00")))

if err := d.Set("version_stages", flex.FlattenStringList(output.VersionStages)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting version_stages: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/secretsmanager_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ This data source exports the following attributes in addition to the arguments a
* `id` - ARN of the secret.
* `tags` - Tags of the secret.
* `policy` - Resource-based policy document that's attached to the secret.
* `created_date` - Created date of the secret in UTC.
* `last_changed_date` - Last updated date of the secret in UTC.
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ This data source exports the following attributes in addition to the arguments a
* `secret_string` - Decrypted part of the protected secret information that was originally provided as a string.
* `secret_binary` - Decrypted part of the protected secret information that was originally provided as a binary.
* `version_id` - Unique identifier of this version of the secret.
* `created_date` - Created date of the secret in UTC.
Loading