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

r/aws_globalaccelerator_accelerator: Add aws_globalaccelerator_accelerator resource #7002

Merged
merged 6 commits into from
Jan 15, 2019

Conversation

gazoakley
Copy link
Contributor

Partly addresses #6739

Changes proposed in this pull request:

  • New Resource: aws_globalaccelerator_accelerator

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAwsGlobalAcceleratorAccelerator'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsGlobalAcceleratorAccelerator -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsGlobalAcceleratorAccelerator_basic
=== PAUSE TestAccAwsGlobalAcceleratorAccelerator_basic
=== RUN   TestAccAwsGlobalAcceleratorAccelerator_update
=== PAUSE TestAccAwsGlobalAcceleratorAccelerator_update
=== RUN   TestAccAwsGlobalAcceleratorAccelerator_attributes
=== PAUSE TestAccAwsGlobalAcceleratorAccelerator_attributes
=== CONT  TestAccAwsGlobalAcceleratorAccelerator_basic
=== CONT  TestAccAwsGlobalAcceleratorAccelerator_attributes
=== CONT  TestAccAwsGlobalAcceleratorAccelerator_update
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_basic (40.31s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_update (64.26s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_attributes (66.62s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	66.665s

@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. dependencies Used to indicate dependency changes. documentation Introduces or discusses updates to documentation. labels Dec 29, 2018
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. labels Jan 3, 2019
@bflad bflad added new-resource Introduces a new resource. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. and removed dependencies Used to indicate dependency changes. labels Jan 8, 2019
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.

Hey @gazoakley 👋 Thanks for submitting this! Initial feedback below. Please reach out with any questions or if you do not have time to address the items.

"ip_address_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this instead include the default for drift detection?

Suggested change
Computed: true,
Default: globalaccelerator.IpAddressTypeIpv4,

"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this instead include the default for drift detection?

Suggested change
Computed: true,
Default: true,

"attributes": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

The DiffSuppressFunc below should allow Computed: true to be removed here.

"flow_logs_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this instead default to false for drift detection?

Suggested change
Computed: true,
Default: false,

"flow_logs_s3_bucket": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we shouldn't be ignoring this value for drift detection and should remove Computed: true.

`, rInt)
}

func testAccGlobalAcceleratorAccelerator_update(rInt int) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test configuration function goes away when using name instead of integer. 👍

testAccCheckGlobalAcceleratorAcceleratorExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "attributes.#", "1"),
resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", "true"),
resource.TestMatchResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", regexp.MustCompile("tf-.*")),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use resource.TestCheckResourceAttrPair() instead of regex to ensure its value is correct.

s3BucketResourceName := "aws_s3_bucket.example"
// ...
resource.TestCheckResourceAttrPair(resourceName, "attributes.0.flow_logs_s3_bucket", s3BucketResourceName, "bucket"),

resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile("tf-.*")),
resource.TestCheckResourceAttr(resourceName, "enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "ip_address_type", "IPV4"),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This check should also include attributes and ip_sets in some form.

globalaccelerator.IpAddressTypeIpv4,
}, false),
},
"enabled": {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should include an acceptance test that creates/updates enabled = true

State: schema.ImportStatePassthrough,
},

Timeouts: &schema.ResourceTimeout{
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation for these custom timeouts is not present on the resource documentation page, but is there a reason why they are customizable to begin with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was good practise to offer customisable timeouts if code needs to do a wait, but I can't imagine users would want to change the defaults very often. Would it be better to add documentation or remove the ability to customize timeouts?

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally want to err on the side of not providing it unless its dependent on some scalable resource (e.g. amount of data in a database) or fluctuates based on AWS-background processes (e.g. varying ENI removal time from load balancers when trying remove subnets). We can always add it later if necessary.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 8, 2019
@gazoakley
Copy link
Contributor Author

Happy New Year @bflad 🎉 - I'll make the updates shortly. One thing I meant to ask about was what would be the best way to deal with deletion when an accelerator is enabled - the call to DeleteAccelerator fails if enabled = true. I could:

  • Automatically call UpdateAccelerator to disable the accelerator, then call DeleteAccelerator
  • Conditionally do the above with some kind of force flag
  • Call DeleteAccelerator, catch the "accelerator is enabled" error and retry after disabling the accelerator

Any preference?

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 8, 2019
@bflad
Copy link
Contributor

bflad commented Jan 8, 2019

Interesting and happy new year as well! Got to love how none of these services are consistent. 😂 First or third option sounds good, whatever is easiest.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 9, 2019
Config: testAccGlobalAcceleratorAccelerator_basic(rName, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckGlobalAcceleratorAcceleratorExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", newName),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be rName 😄

--- FAIL: TestAccAwsGlobalAcceleratorAccelerator_update (35.05s)
    testing.go:538: Step 0 error: Check failed: Check 2/3 error: aws_globalaccelerator_accelerator.example: Attribute 'name' expected "tf-acc-test-1060790186692934857", got "tf-acc-test-4121192575072923489"
Suggested change
resource.TestCheckResourceAttr(resourceName, "name", newName),
resource.TestCheckResourceAttr(resourceName, "name", rName),

bflad added a commit that referenced this pull request Jan 15, 2019
Changes:

* Remove `Computed: true` from `attributes` attribute
* Fix `TestAccAwsGlobalAcceleratorAccelerator_update` check

Output from acceptance testing:

```
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_basic (55.12s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_attributes (69.74s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_update (89.72s)
```
@bflad bflad added this to the v1.56.0 milestone Jan 15, 2019
@bflad bflad merged commit dfc5950 into hashicorp:master Jan 15, 2019
@bflad
Copy link
Contributor

bflad commented Jan 15, 2019

Whoops didn't post my approval first 😅 Thanks, @gazoakley! 🚀

--- PASS: TestAccAwsGlobalAcceleratorAccelerator_basic (55.12s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_attributes (69.74s)
--- PASS: TestAccAwsGlobalAcceleratorAccelerator_update (89.72s)

bflad added a commit that referenced this pull request Jan 15, 2019
@bflad
Copy link
Contributor

bflad commented Jan 16, 2019

This has been released in version 1.56.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 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 1, 2020
@gazoakley gazoakley deleted the f-globalaccelerator-accelerator branch April 7, 2020 16:17
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/globalaccelerator Issues and PRs that pertain to the globalaccelerator service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants