-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
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 @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.
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) |
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.
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()
:
d.Set("tags", r.Tags) | |
if err := d.Set("tags", tagsToMapRAM(r.Tags)); err != nil { | |
return fmt.Errorf("error setting tags: %s", err) | |
} |
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 === RUN TestAccDataSourceAwsRamResourceShare_Tags |
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.
Looks great, @robh007, thanks! 🚀
--- PASS: TestAccDataSourceAwsRamResourceShare_Tags (16.75s)
--- PASS: TestAccDataSourceAwsRamResourceShare_Basic (17.38s)
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. |
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! |
Community Note
Fixes #8280
Changes proposed in this pull request:
aws_ram_resource_share
Lookup RAM resource shares.
example
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