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

tests/service/guardduty: Add PreCheck or ErrorCheck for Existing Detector #18619

Closed
bflad opened this issue Apr 7, 2021 · 3 comments · Fixed by #31463
Closed

tests/service/guardduty: Add PreCheck or ErrorCheck for Existing Detector #18619

bflad opened this issue Apr 7, 2021 · 3 comments · Fixed by #31463
Labels
service/guardduty Issues and PRs that pertain to the guardduty service. stale Old or inactive issues managed by automation, if no further action taken these will get closed. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Apr 7, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

GuardDuty only allows one Detector per account and certain testing accounts may already have that Detector (e.g. managed by security teams). Currently the acceptance testing will fail with errors like the below in that situation:

=== RUN   TestAccAWSGuardDuty_serial/Detector/basic
resource_aws_guardduty_detector_test.go:73: Step 1/5 error: Error running apply: exit status 1
Error: Creating GuardDuty Detector failed: BadRequestException: The request is rejected because a detector already exists for the current account.
{
RespMetadata: {
StatusCode: 400,
RequestID: "7725956a-aacf-4cd3-8f54-f47fa817ee84"
},
Message_: "The request is rejected because a detector already exists for the current account.",
Type: "InvalidInputException"
}
on terraform_plugin_test.tf line 2, in resource "aws_guardduty_detector" "test":
2: resource "aws_guardduty_detector" "test" {}
--- FAIL: TestAccAWSGuardDuty_serial/Detector/basic (15.17s)

Instead, the acceptance testing should mark these tests as skipped. Preferably, this can be done with a PreCheck function that uses ListDetectors to see if there is already an existing Detector identifier rather than fail during the apply of the test configuration. Otherwise, it can be done with registering an ErrorCheck for the service.

Affected Resources

  • aws_guardduty_detector
  • aws_guardduty_filter
  • aws_guardduty_ip_set
  • aws_guardduty_publishing_destination
  • aws_guardduty_threat_intel_set
@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/guardduty Issues and PRs that pertain to the guardduty service. labels Apr 7, 2021
@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Mar 28, 2023
@github-actions github-actions bot added this to the v5.20.0 milestone Sep 29, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

This functionality has been released in v5.20.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!

Copy link

github-actions bot commented Nov 6, 2023

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/guardduty Issues and PRs that pertain to the guardduty service. stale Old or inactive issues managed by automation, if no further action taken these will get closed. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant