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

New Resource: aws_guardduty_ipset #3161

Merged
merged 3 commits into from
Jan 30, 2018

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi atsushi-ishibashi commented Jan 27, 2018

#2489

TF_ACC=1 go test ./aws -v -run=TestAccAwsGuardDutyIpset_basic -timeout 120m
=== RUN   TestAccAwsGuardDutyIpset_basic
--- PASS: TestAccAwsGuardDutyIpset_basic (164.15s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	164.185s

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jan 27, 2018
@atsushi-ishibashi atsushi-ishibashi changed the title New Resource: guardduty_ipset New Resource: aws_guardduty_ipset Jan 27, 2018
@bflad bflad added new-resource Introduces a new resource. service/guardduty Issues and PRs that pertain to the guardduty service. labels Jan 28, 2018
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.

Overall this is looking pretty good! Let me know if you can or when you address these comments and I'll take another look. 👍

return fmt.Errorf("[WARN] Error waiting for GuardDuty IpSet status to be \"%s\": %s", guardduty.IpSetStatusActive, err)
}

d.SetId(*resp.IpSetId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make the resource ID fmt.Sprintf("%s:%s", detectorID, *resp.IpSetId) so we can also add the passthrough import please?

`, testAccGuardDutyDetectorConfig_basic1, rName, rName, rName)
}

func testAccGuardDutyIpsetConfig_update(rName, modName string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Can you make the Config_basic able to take in all the required inputs so we don't need two configuration functions please?


func validateGuardDutyIpsetFormat(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
validType := []string{"TXT", "STIX", "OTX_CSV", "ALIEN_VAULT", "PROOF_POINT", "FIRE_EYE"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Can you use the SDK provided constants please? e.g. guardduty.IpSetFormatAlienVault


# aws_guardduty_ipset

Provides a resource to manage a GuardDuty detector.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copypasta: Should be GuardDuty IPSet

Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to include the note from the GuardDuty API documentation here.

~> **Note:** Currently in GuardDuty, users from member accounts cannot upload and further manage IPSets. IPSets that are uploaded by the master account are imposed on GuardDuty functionality in its member accounts.

if !ok {
return fmt.Errorf("Not found: %s", name)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally we try to verify the resources actually exist in AWS in these. Once the ID is updated, you can do that here. 👍

}
return err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to d.Set("activate", *resp.Status == guardduty.IpSetStatusActive) here. We may want to consider renaming the attribute active.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 29, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jan 29, 2018
@atsushi-ishibashi
Copy link
Contributor Author

TF_ACC=1 go test ./aws -v -run=TestAccAwsGuardDutyIpset_* -timeout 120m
=== RUN   TestAccAwsGuardDutyIpset_basic
--- PASS: TestAccAwsGuardDutyIpset_basic (212.81s)
=== RUN   TestAccAwsGuardDutyIpset_import
--- FAIL: TestAccAwsGuardDutyIpset_import (114.30s)
	testing.go:513: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
		
		(map[string]string) {
		}
		
		
		(map[string]string) (len=1) {
		 (string) (len=11) "detector_id": (string) (len=32) "c8b0a11cff4d9f541ec460da3967be55"
		}
		
FAIL
exit status 1
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	327.160s
make: *** [testacc] Error 1

I didn't understand how Importer works so could you help me? @bflad

@bflad
Copy link
Contributor

bflad commented Jan 29, 2018

@atsushi-ishibashi d.Set("detector_id", detectorId) in the read function from the value you get from parsing the ID 😄

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jan 29, 2018
@atsushi-ishibashi
Copy link
Contributor Author

@bflad Thank you!

TF_ACC=1 go test ./aws -v -run=TestAccAwsGuardDutyIpset_import -timeout 120m
=== RUN   TestAccAwsGuardDutyIpset_import
--- PASS: TestAccAwsGuardDutyIpset_import (79.31s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	79.360s

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 30, 2018
@bflad
Copy link
Contributor

bflad commented Jan 30, 2018

Thanks so much @atsushi-ishibashi! This looks great and I'll be merging it momentarily. :shipit:

make testacc TEST=./aws TESTARGS='-run=TestAccAwsGuardDutyIpset'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAwsGuardDutyIpset -timeout 120m
=== RUN   TestAccAwsGuardDutyIpset_basic
--- PASS: TestAccAwsGuardDutyIpset_basic (56.88s)
=== RUN   TestAccAwsGuardDutyIpset_import
--- PASS: TestAccAwsGuardDutyIpset_import (35.16s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	92.090s

FYI I will be adding one very minor commit to this, its needed to ensure the acceptance testing works when run in parallel testing environments (like our daily repository acceptance testing) since GuardDuty only allows one detector in each account at a time (check out: https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_guardduty_test.go). We don't expect most folks to know or worry about this most of the time since we're very appreciative of make testacc runners already! 🥇

@atsushi-ishibashi
Copy link
Contributor Author

@bflad I got it. Thank you!

@bflad bflad merged commit c77a96c into hashicorp:master Jan 30, 2018
bflad added a commit that referenced this pull request Jan 30, 2018
@bflad bflad added this to the v1.9.0 milestone Jan 30, 2018
@bflad
Copy link
Contributor

bflad commented Feb 9, 2018

This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 8, 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 Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/guardduty Issues and PRs that pertain to the guardduty service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants