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

d/aws_ram_resource_share: Adding new data source for RAM resource share #8491

Merged
merged 3 commits into from
May 14, 2019

Conversation

robh007
Copy link
Contributor

@robh007 robh007 commented May 1, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #8280

Changes proposed in this pull request:

  • Adds a new data resource aws_ram_resource_share

Lookup RAM resource shares.

example

data "aws_ram_resource_share" "example" {
  name = "example-name"
  resource_owner = "SELF"
}

Output from acceptance testing:
make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAwsRamResourceShare_Basic' [9:44:23]
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccDataSourceAwsRamResourceShare_Basic -timeout 120m
=== RUN TestAccDataSourceAwsRamResourceShare_Basic
=== PAUSE TestAccDataSourceAwsRamResourceShare_Basic
=== CONT TestAccDataSourceAwsRamResourceShare_Basic
--- PASS: TestAccDataSourceAwsRamResourceShare_Basic (33.49s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 33.540s

make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAwsRamResourceShare_Tags' [9:45:51]
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccDataSourceAwsRamResourceShare_Tags -timeout 120m
=== RUN TestAccDataSourceAwsRamResourceShare_Tags
=== PAUSE TestAccDataSourceAwsRamResourceShare_Tags
=== CONT TestAccDataSourceAwsRamResourceShare_Tags
--- PASS: TestAccDataSourceAwsRamResourceShare_Tags (30.48s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 30.526s

$ make testacc TESTARGS='-run=TestAccDataSourceAwsRamResourceShare_Basic'
$ make testacc TESTARGS='-run=TestAccDataSourceAwsRamResourceShare_Tags'
...

@ghost ghost added size/L Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels May 1, 2019
@bflad bflad added new-data-source Introduces a new data source. service/ram Issues and PRs that pertain to the ram service. labels May 6, 2019
@bflad bflad self-assigned this May 13, 2019
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 @robh007 👋 Thanks for submitting this! Overall looking pretty good, just left a few items below and we should be able to get this in. Please reach out if you have any questions or do not have time to implement the feedback.

aws/data_source_aws_ram_resource_share.go Show resolved Hide resolved
d.Set("arn", aws.StringValue(r.ResourceShareArn))
d.Set("owning_account_id", aws.StringValue(r.OwningAccountId))
d.Set("status", aws.StringValue(r.Status))
d.Set("tags", r.Tags)
Copy link
Contributor

Choose a reason for hiding this comment

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

When using d.Set() with aggregate types (TypeList, TypeSet, TypeMap), we should perform error checking to prevent issues where the code is not properly able to set the Terraform state. e.g.

				if err := d.Set("tags", r.Tags); err != nil {
					return fmt.Errorf("error setting tags: %s", err)
				}

After adding this error checking, you should start receiving type errors as r.Tags is a []*ram.Tag and not an acceptable type for d.Set(). Looking at the existing aws_ram_resource_share resource logic, we should be able to borrow its functionality here with tagsToMapRAM():

Suggested change
d.Set("tags", r.Tags)
if err := d.Set("tags", tagsToMapRAM(r.Tags)); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label May 13, 2019
@robh007
Copy link
Contributor Author

robh007 commented May 14, 2019

Hi @bflad, thanks for the feedback & providing help. I've made the suggested changes & re-ran the tests which are passing. Let me know if anything else is needed from me.

=== RUN TestAccDataSourceAwsRamResourceShare_Basic
=== PAUSE TestAccDataSourceAwsRamResourceShare_Basic
=== CONT TestAccDataSourceAwsRamResourceShare_Basic
--- PASS: TestAccDataSourceAwsRamResourceShare_Basic (18.45s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 18.500s

=== RUN TestAccDataSourceAwsRamResourceShare_Tags
=== PAUSE TestAccDataSourceAwsRamResourceShare_Tags
=== CONT TestAccDataSourceAwsRamResourceShare_Tags
--- PASS: TestAccDataSourceAwsRamResourceShare_Tags (14.18s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 14.237s

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label May 14, 2019
@bflad bflad added this to the v2.11.0 milestone May 14, 2019
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.

Looks great, @robh007, thanks! 🚀

--- PASS: TestAccDataSourceAwsRamResourceShare_Tags (16.75s)
--- PASS: TestAccDataSourceAwsRamResourceShare_Basic (17.38s)

@bflad bflad merged commit 74de47b into hashicorp:master May 14, 2019
bflad added a commit that referenced this pull request May 14, 2019
@bflad
Copy link
Contributor

bflad commented May 17, 2019

This has been released in version 2.11.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 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. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/ram Issues and PRs that pertain to the ram service. size/L 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.

aws_ram_resource_share Data Source?
2 participants