Skip to content

Commit

Permalink
service/globalaccelerator: Support Client IP address preservation, in…
Browse files Browse the repository at this point in the history
…crease default accelerator creation timeout, remove health_check_path default (hashicorp#14486)

* Add client_ip_preservation_enabled to global accelerator

* commit test

* r/aws_globalaccelerator_endpoint_group: Use 'tfawsresource.TestCheckTypeSetElemNestedAttrs'.

* r/aws_globalaccelerator_endpoint: Increase deployment wait time (hashicorp#14161).

* r/aws_globalaccelerator_endpoint_group: Make 'client_ip_preservation_enabled' computed.

* r/aws_globalaccelerator_endpoint_group: Delete security group created by Global Accelerator service in acceptance tests.

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP
--- PASS: TestAccAwsGlobalAcceleratorEndpointGroup_ALB_ClientIP (650.27s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	650.320s

* r/aws_globalaccelerator_endpoint_group: Document 'client_ip_preservation_enabled'.

* r/aws_globalaccelerator_endpoint_group: Add 'TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint'.

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint
    testing.go:684: Step 0 error: errors during apply:

        Error: Error creating Global Accelerator endpoint group: InvalidArgumentException: Client IP Preservation cannot be set to false for EC2 instances

          on /tmp/tf-test004466997/main.tf line 86:
          (source code not available)

--- FAIL: TestAccAwsGlobalAcceleratorEndpointGroup_InstanceEndpoint (133.29s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	133.338s
FAIL
GNUmakefile:26: recipe for target 'testacc' failed
make: *** [testacc] Error 1

* r/aws_globalaccelerator_endpoint_group: Simplify 'TestAccAwsGlobalAcceleratorEndpointGroup_basic'.

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_basic -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_basic
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_basic
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_basic
    testing.go:684: Step 0 error: After applying this step, the plan was not empty:

        DIFF:

        UPDATE: aws_globalaccelerator_endpoint_group.test
          endpoint_configuration.#:      "0" => "0"
          endpoint_group_region:         "us-west-2" => "us-west-2"
          health_check_interval_seconds: "30" => "30"
          health_check_path:             "" => "/"
          health_check_port:             "80" => ""
          health_check_protocol:         "TCP" => "TCP"
          id:                            "arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59/endpoint-group/e84317b2d005" => "arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59/endpoint-group/e84317b2d005"
          listener_arn:                  "arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59" => "arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59"
          threshold_count:               "3" => "3"
          traffic_dial_percentage:       "100" => "100"

        STATE:

        aws_globalaccelerator_accelerator.test:
          ID = arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0
          provider = provider.aws
          attributes.# = 1
          attributes.0.flow_logs_enabled = false
          attributes.0.flow_logs_s3_bucket =
          attributes.0.flow_logs_s3_prefix =
          dns_name = a9225ffbbaaf25cce.awsglobalaccelerator.com
          enabled = false
          hosted_zone_id = Z2BJ6XQ5FK7U4H
          ip_address_type = IPV4
          ip_sets.# = 1
          ip_sets.0.ip_addresses.# = 2
          ip_sets.0.ip_addresses.0 = 75.2.20.133
          ip_sets.0.ip_addresses.1 = 99.83.169.50
          ip_sets.0.ip_family = IPv4
          name = tf-acc-test-809980946792323534
        aws_globalaccelerator_endpoint_group.test:
          ID = arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59/endpoint-group/e84317b2d005
          provider = provider.aws
          endpoint_group_region = us-west-2
          health_check_interval_seconds = 30
          health_check_path =
          health_check_port = 80
          health_check_protocol = TCP
          listener_arn = arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59
          threshold_count = 3
          traffic_dial_percentage = 100

          Dependencies:
            aws_globalaccelerator_listener.test
        aws_globalaccelerator_listener.test:
          ID = arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0/listener/38d2eb59
          provider = provider.aws
          accelerator_arn = arn:aws:globalaccelerator::xxxxxxxxxxxx:accelerator/9e848383-b09a-4439-ac4f-eacb46aa04c0
          client_affinity = NONE
          port_range.# = 1
          port_range.0.from_port = 80
          port_range.0.to_port = 80
          protocol = TCP

          Dependencies:
            aws_globalaccelerator_accelerator.test
--- FAIL: TestAccAwsGlobalAcceleratorEndpointGroup_basic (179.82s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	179.872s
FAIL
GNUmakefile:26: recipe for target 'testacc' failed
make: *** [testacc] Error 1

* Fix health_check_path for GA TCP endpoint group

- Set `health_check_path` to Computed without Default
- Update documentation

* Update website/docs/r/globalaccelerator_endpoint_group.html.markdown

Co-authored-by: Brian Flad <[email protected]>

* r/aws_globalaccelerator_endpoint_group: Change 'health_check_port' to Computed (hashicorp#12882).

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_basic -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_basic
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_basic
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_basic
--- PASS: TestAccAwsGlobalAcceleratorEndpointGroup_basic (183.26s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	183.312s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_update'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_update -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_update
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_update
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_update
--- PASS: TestAccAwsGlobalAcceleratorEndpointGroup_update (241.78s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	241.856s

* r/aws_globalaccelerator_endpoint_group: Add '_disappears' acceptance test (hashicorp#13527, hashicorp#13826).

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsGlobalAcceleratorEndpointGroup_disappears'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsGlobalAcceleratorEndpointGroup_disappears -timeout 120m
=== RUN   TestAccAwsGlobalAcceleratorEndpointGroup_disappears
=== PAUSE TestAccAwsGlobalAcceleratorEndpointGroup_disappears
=== CONT  TestAccAwsGlobalAcceleratorEndpointGroup_disappears
--- PASS: TestAccAwsGlobalAcceleratorEndpointGroup_disappears (191.83s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	191.883s

* r/aws_globalaccelerator_endpoint_group: Set 'client_ip_preservation_enabled' to 'true' for EC2 instance endpoint test.

Co-authored-by: Zuhaib Siddique <[email protected]>
Co-authored-by: LOU Xun <[email protected]>
Co-authored-by: Brian Flad <[email protected]>
  • Loading branch information
4 people authored Aug 22, 2020
1 parent 8618ccb commit 8a060a4
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 36 deletions.
2 changes: 1 addition & 1 deletion aws/resource_aws_globalaccelerator_accelerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func resourceAwsGlobalAcceleratorAcceleratorWaitForDeployedState(conn *globalacc
Pending: []string{globalaccelerator.AcceleratorStatusInProgress},
Target: []string{globalaccelerator.AcceleratorStatusDeployed},
Refresh: resourceAwsGlobalAcceleratorAcceleratorStateRefreshFunc(conn, acceleratorArn),
Timeout: 5 * time.Minute,
Timeout: 10 * time.Minute,
}

log.Printf("[DEBUG] Waiting for Global Accelerator accelerator (%s) availability", acceleratorArn)
Expand Down
10 changes: 9 additions & 1 deletion aws/resource_aws_globalaccelerator_endpoint_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ func resourceAwsGlobalAcceleratorEndpointGroup() *schema.Resource {
"health_check_path": {
Type: schema.TypeString,
Optional: true,
Default: "/",
Computed: true,
},
"health_check_port": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"health_check_protocol": {
Type: schema.TypeString,
Expand Down Expand Up @@ -87,6 +88,11 @@ func resourceAwsGlobalAcceleratorEndpointGroup() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"client_ip_preservation_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -213,6 +219,7 @@ func resourceAwsGlobalAcceleratorEndpointGroupExpandEndpointConfigurations(confi

m.EndpointId = aws.String(configuration["endpoint_id"].(string))
m.Weight = aws.Int64(int64(configuration["weight"].(int)))
m.ClientIPPreservationEnabled = aws.Bool(configuration["client_ip_preservation_enabled"].(bool))

out[i] = &m
}
Expand All @@ -229,6 +236,7 @@ func resourceAwsGlobalAcceleratorEndpointGroupFlattenEndpointDescriptions(config

m["endpoint_id"] = aws.StringValue(configuration.EndpointId)
m["weight"] = aws.Int64Value(configuration.Weight)
m["client_ip_preservation_enabled"] = aws.BoolValue(configuration.ClientIPPreservationEnabled)

out[i] = m
}
Expand Down
Loading

0 comments on commit 8a060a4

Please sign in to comment.