-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Support for policy in secrets manager datasource #6091
Support for policy in secrets manager datasource #6091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tkbky 👋 Thanks for submitting this! Left some initial (minor) feedback. We should be able to get this in after. Please let us know if you do not have time to implement the feedback or if you have any questions.
return fmt.Errorf("error reading Secrets Manager Secret policy: %s", err) | ||
} | ||
|
||
if pOut.ResourcePolicy != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are performing nil
checks here, we should also ensure pOut
is not nil
as well to prevent the panic 😄
if pOut != nil && pOut.ResourcePolicy != nil {
@@ -34,6 +35,11 @@ func dataSourceAwsSecretsManagerSecret() *schema.Resource { | |||
Optional: true, | |||
Computed: true, | |||
}, | |||
"policy": { | |||
Type: schema.TypeString, | |||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not providing policy
as a configurable argument to lookup the secret, we should remove Optional: true
here. 👍
|
||
data "aws_secretsmanager_secret" "test" { | ||
name = "${aws_secretsmanager_secret.test.name}" | ||
policy = "${aws_secretsmanager_secret.test.policy}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The formatting seems off here, maybe spaces vs tabs?
@bflad thanks for reviewing the PR. I'll make the changes accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @tkbky! 🚀
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Basic (2.16s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Name (4.73s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_ARN (4.81s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_VersionID (4.96s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Policy (5.01s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_VersionStage (5.04s)
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_Basic (5.54s)
@bflad Thank you so much. |
This has been released in version 1.40.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Fixes #5329
Changes proposed in this pull request:
Output from acceptance testing: