-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Added guardduty filter resource #10676
Conversation
Hi there! I see you have hundreds of pull requests, folks :( Is there any chance I can speed up a review for this one? |
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.
Thanks for the PR, @graffzon, it looks good. I have a few changes for you to make
Config: testAccGuardDutyFilterConfig_full(), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsGuardDutyFilterExists(resourceName), | ||
resource.TestCheckResourceAttrSet(resourceName, "detector_id"), |
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.
Use resource.TestCheckResourceAttrPair
to verify that the correct value is set
Hi @graffzon, are you still interested in working on this PR? |
@graffzon @gdavison Can I contribute to this pull request? I checked out this pull request and added some commits according to the review comments. Should I create a new pull request? Or is there any other way? Thank you. |
Hi folks, my apologies for keeping silence. @suzuki-shunsuke if you have time and willingness to contribute to this PR - I'd be happy. Unfortunately I don't have a prepared setup to test the GuardDuty resources anymore. However, if it will hang for a couple more months, I might have time to come back to it 😅 |
@suzuki-shunsuke I found a way to merge your changes into this PR, thanks a lot for your work. |
Merging master into feature branch
@suzuki-shunsuke Thanks for being that quick :) |
@graffzon
Would you cherry pick 045794d and 53d0e17 instead of bb3819c 255ff95?
|
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.
Thanks for the updates, @graffzon and @suzuki-shunsuke. I've done a deeper review of the PR and have a number of changes to make
aws/resource_aws_guardduty_filter.go
Outdated
|
||
criteria := make(map[string]*schema.Set) | ||
|
||
criteria["criterion"] = schema.NewSet(schema.HashResource(criterionResource()), flatCriteria) |
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.
criterionResource()
should not redefine the schema here. The best option is probably to define a hash function that can be used here and set it on the schema as well.
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.
aws/resource_aws_guardduty_filter.go
Outdated
flatCriterion["field"] = field | ||
flatCriterion["condition"] = conditionName | ||
flatCriterion["values"] = make([]interface{}, 1) | ||
flatCriterion["values"].([]interface{})[0] = strconv.FormatInt(*conditionValue, 10) |
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.
strconv.Itoa()
would be a simpler function to use here, since we don't need to specify the base.
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.
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.
The type of *conditionValue
is int64
but the type of the argument strconv.Itoa
is int
.
So strconv.FormatInt
isn't wrong.
aws/resource_aws_guardduty_filter.go
Outdated
|
||
for field, conditions := range findingCriteriaRemote.Criterion { | ||
if len(conditions.Equals) > 0 { | ||
flatCriteria = append(flatCriteria, flattenStringCondition(field, "equals", conditions.Equals)) |
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.
The two flattenStringCondition()
calls here could take a []string
parameter, and have the dereference happen here
flatCriteria = append(flatCriteria, flattenStringCondition(field, "equals", conditions.Equals)) | |
flatCriteria = append(flatCriteria, flattenStringCondition(field, "equals", aws.StringValueSlice(conditions.Equals))) |
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.
aws/resource_aws_guardduty_filter.go
Outdated
flatCriteria = append(flatCriteria, flattenStringCondition(field, "not_equals", conditions.NotEquals)) | ||
} | ||
if conditions.GreaterThan != nil { | ||
flatCriteria = append(flatCriteria, flattenIntCondition(field, "greater_than", conditions.GreaterThan)) |
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.
The four flattenIntCondition()
calls here could take an int
parameter and have the dereference happen here
flatCriteria = append(flatCriteria, flattenIntCondition(field, "greater_than", conditions.GreaterThan)) | |
flatCriteria = append(flatCriteria, flattenIntCondition(field, "greater_than", int(aws.Int64Value(conditions.GreaterThan)))) |
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.
aws/resource_aws_guardduty_filter.go
Outdated
"NOOP", | ||
"ARCHIVE", |
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.
These should be replaced by the constants defined in the AWS SDK
"NOOP", | |
"ARCHIVE", | |
guardduty.FilterActionNoop, | |
guardduty..FilterActionArchive, |
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.
@gdavison Thank you for your review. |
Hi @graffzon and @suzuki-shunsuke. We'd like to get this merged in. @graffzon do you want to merge @suzuki-shunsuke's changes into your PR, or @suzuki-shunsuke do you want to create a PR from your branch? We'll also need to update the version of the Terraform SDK plugin to v2. Update references to the package $ git fetch --all
$ git rebase origin/master |
54c10e1
to
e313e2b
Compare
8dcad82
to
e313e2b
Compare
Thanks for your tremendous effort @gdavison and @suzuki-shunsuke !!! 🙏 |
Thanks again for all the work you've put in, @graffzon and @suzuki-shunsuke. There are a few remaining changes we'd like to see before merging the PR. If one of you would like to make the changes go ahead. Otherwise, I can make the changes next week (24 August) so that we can get it in for the release that week. |
This has been released in version 3.5.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 for triage. Thanks! |
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
Relates OR Closes #0000 (Sorry, I didn't get, shall I create an issue for this PR or the PR on its own is enough?)
Release note for CHANGELOG:
Output from acceptance testing: