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

Support for policy in secrets manager datasource #6091

Merged

Conversation

tkbky
Copy link
Contributor

@tkbky tkbky commented Oct 8, 2018

Fixes #5329

Changes proposed in this pull request:

  • Add support for the policy in secrets manager's data source.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccDataSourceAwsSecretsManagerSecret'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccDataSourceAwsSecretsManagerSecret -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccDataSourceAwsSecretsManagerSecret_Basic
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Basic (12.48s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecret_ARN
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_ARN (34.63s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecret_Name
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Name (34.90s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecret_Policy
--- PASS: TestAccDataSourceAwsSecretsManagerSecret_Policy (39.18s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecretVersion_Basic
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_Basic (41.26s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecretVersion_VersionID
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_VersionID (38.00s)
=== RUN   TestAccDataSourceAwsSecretsManagerSecretVersion_VersionStage
--- PASS: TestAccDataSourceAwsSecretsManagerSecretVersion_VersionStage (39.45s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	239.940s
...

@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 8, 2018
@bflad bflad added the service/secretsmanager Issues and PRs that pertain to the secretsmanager service. label Oct 8, 2018
Copy link
Contributor

@bflad bflad left a 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.

aws/data_source_aws_secretsmanager_secret.go Show resolved Hide resolved
return fmt.Errorf("error reading Secrets Manager Secret policy: %s", err)
}

if pOut.ResourcePolicy != nil {
Copy link
Contributor

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,
Copy link
Contributor

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}"
Copy link
Contributor

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 bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Oct 8, 2018
@tkbky
Copy link
Contributor Author

tkbky commented Oct 8, 2018

@bflad thanks for reviewing the PR. I'll make the changes accordingly.

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Oct 9, 2018
@bflad bflad added this to the v1.40.0 milestone Oct 9, 2018
Copy link
Contributor

@bflad bflad left a 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 bflad merged commit b50cf8d into hashicorp:master Oct 9, 2018
bflad added a commit that referenced this pull request Oct 9, 2018
@tkbky
Copy link
Contributor Author

tkbky commented Oct 9, 2018

@bflad Thank you so much.

@bflad
Copy link
Contributor

bflad commented Oct 10, 2018

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.

@ghost
Copy link

ghost commented Apr 2, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. service/secretsmanager Issues and PRs that pertain to the secretsmanager service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resource based policy for secrets manager secrets
2 participants