-
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
Proposal: Add more fine-grained errors for finder functions #17613
Conversation
5ed5225
to
fc9910e
Compare
My recommendation here would be to first document the existing Another consideration here is that we likely have quite a few error handling scenarios we want to ensure we are consistently encoding across all packages, not just Resource Not FoundApplicable to:
Explicitly converting AWS service error codes or missing results into the common Expected uses:
Empty API ResponseApplicable to:
If the API response includes missing output types (e.g. empty Go pointers). Expected uses:
Multiple API ResponseApplicable to:
If the API response includes multiple objects, but we expect only one object. Expected uses:
|
Related to the above, I have created two tracking issues: |
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 🚀.
Commercial
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSDefaultSecurityGroup_\|TestAccDataSourceAwsSecurityGroup_\|TestAccAWSELB_SecurityGroups'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSDefaultSecurityGroup_\|TestAccDataSourceAwsSecurityGroup_\|TestAccAWSELB_SecurityGroups -timeout 120m
=== RUN TestAccDataSourceAwsSecurityGroup_basic
=== PAUSE TestAccDataSourceAwsSecurityGroup_basic
=== RUN TestAccAWSDefaultSecurityGroup_Vpc_basic
=== PAUSE TestAccAWSDefaultSecurityGroup_Vpc_basic
=== RUN TestAccAWSDefaultSecurityGroup_Vpc_empty
=== PAUSE TestAccAWSDefaultSecurityGroup_Vpc_empty
=== RUN TestAccAWSDefaultSecurityGroup_Classic_basic
=== PAUSE TestAccAWSDefaultSecurityGroup_Classic_basic
=== RUN TestAccAWSDefaultSecurityGroup_Classic_empty
provider_test.go:56: This resource does not currently clear tags when adopting the resource
--- SKIP: TestAccAWSDefaultSecurityGroup_Classic_empty (0.00s)
=== RUN TestAccAWSELB_SecurityGroups
=== PAUSE TestAccAWSELB_SecurityGroups
=== CONT TestAccDataSourceAwsSecurityGroup_basic
=== CONT TestAccAWSDefaultSecurityGroup_Classic_basic
=== CONT TestAccAWSELB_SecurityGroups
=== CONT TestAccAWSDefaultSecurityGroup_Vpc_empty
=== CONT TestAccAWSDefaultSecurityGroup_Vpc_basic
--- PASS: TestAccAWSDefaultSecurityGroup_Classic_basic (13.54s)
--- PASS: TestAccDataSourceAwsSecurityGroup_basic (24.25s)
--- PASS: TestAccAWSDefaultSecurityGroup_Vpc_empty (28.20s)
--- PASS: TestAccAWSELB_SecurityGroups (41.01s)
--- PASS: TestAccAWSDefaultSecurityGroup_Vpc_basic (46.07s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 48.880s
GovCloud
% make testacc TEST=./aws TESTARGS='-run=TestAccAWSDefaultSecurityGroup_\|TestAccDataSourceAwsSecurityGroup_\|TestAccAWSELB_SecurityGroups'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSDefaultSecurityGroup_\|TestAccDataSourceAwsSecurityGroup_\|TestAccAWSELB_SecurityGroups -timeout 120m
=== RUN TestAccDataSourceAwsSecurityGroup_basic
=== PAUSE TestAccDataSourceAwsSecurityGroup_basic
=== RUN TestAccAWSDefaultSecurityGroup_Vpc_basic
=== PAUSE TestAccAWSDefaultSecurityGroup_Vpc_basic
=== RUN TestAccAWSDefaultSecurityGroup_Vpc_empty
=== PAUSE TestAccAWSDefaultSecurityGroup_Vpc_empty
=== RUN TestAccAWSDefaultSecurityGroup_Classic_basic
=== PAUSE TestAccAWSDefaultSecurityGroup_Classic_basic
=== RUN TestAccAWSDefaultSecurityGroup_Classic_empty
provider_test.go:56: This resource does not currently clear tags when adopting the resource
--- SKIP: TestAccAWSDefaultSecurityGroup_Classic_empty (0.00s)
=== RUN TestAccAWSELB_SecurityGroups
=== PAUSE TestAccAWSELB_SecurityGroups
=== CONT TestAccDataSourceAwsSecurityGroup_basic
=== CONT TestAccAWSDefaultSecurityGroup_Classic_basic
=== CONT TestAccAWSDefaultSecurityGroup_Vpc_empty
=== CONT TestAccAWSELB_SecurityGroups
=== CONT TestAccAWSDefaultSecurityGroup_Vpc_basic
=== CONT TestAccAWSDefaultSecurityGroup_Classic_basic
ec2_classic_test.go:54: this test can only run in EC2-Classic, platforms available in us-gov-west-1: ["VPC"]
--- SKIP: TestAccAWSDefaultSecurityGroup_Classic_basic (2.52s)
--- PASS: TestAccDataSourceAwsSecurityGroup_basic (27.38s)
--- PASS: TestAccAWSDefaultSecurityGroup_Vpc_empty (31.82s)
--- PASS: TestAccAWSELB_SecurityGroups (49.64s)
--- PASS: TestAccAWSDefaultSecurityGroup_Vpc_basic (52.89s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 55.663s
…ror and expands use of Security Group finder
fc9910e
to
8cb4a0e
Compare
This functionality has been released in v3.55.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Adds
EmptyResultError
andTooManyResultsError
as additional error cases for finder functions such asSecurityGroupByID()
to replace testing the error message for string equality.These two new errors can still be handled by
isResourceNotFoundError()
or anerrors.As()
check. In addition, definesErrEmptyResult
andErrTooManyResults
which can be used inerrors.Is()
checks.Examples:
replaces
Output from acceptance testing: