diff --git a/aws/resource_aws_lb_target_group_test.go b/aws/resource_aws_lb_target_group_test.go index d9944d532d8..28556992980 100644 --- a/aws/resource_aws_lb_target_group_test.go +++ b/aws/resource_aws_lb_target_group_test.go @@ -1050,7 +1050,7 @@ resource "aws_lb_target_group" "test" { vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 - slow_start = 0 + slow_start = 0 # HTTP Only stickiness { @@ -1059,13 +1059,12 @@ resource "aws_lb_target_group" "test" { } health_check { - interval = 10 - port = 8081 - protocol = "HTTP" - healthy_threshold = 3 + interval = 10 + port = 8081 + protocol = "HTTP" + healthy_threshold = 3 unhealthy_threshold = 3 } - tags = { Name = "TestAccAWSLBTargetGroup_application_LB_defaults" } @@ -1077,8 +1076,7 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-alb-defaults" } -} -`, name) +}`, name) } func testAccNLB_defaults(name, healthCheckBlock string) string { @@ -1107,35 +1105,33 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-nlb-defaults" } -} -`, name, healthCheckBlock) +}`, name, healthCheckBlock) } func testAccAWSLBTargetGroupConfig_basic(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 - slow_start = 0 + slow_start = 0 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { @@ -1149,44 +1145,40 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-basic" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_withoutHealthcheck(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" target_type = "lambda" -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfigBackwardsCompatibility(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_alb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_alb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 - slow_start = 0 + slow_start = 0 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { @@ -1200,48 +1192,44 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-bc" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_enableHealthcheck(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" target_type = "lambda" health_check { - path = "/health" + path = "/health" interval = 60 } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_updatedPort(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 442 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 442 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { @@ -1255,34 +1243,32 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-basic" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_updatedProtocol(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTP" - vpc_id = "${aws_vpc.test2.id}" + vpc_id = "${aws_vpc.test2.id}" deregistration_delay = 200 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { @@ -1304,34 +1290,32 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-basic" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_updatedVpc(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { @@ -1345,39 +1329,37 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-updated-vpc" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_updateTags(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health" - interval = 60 - port = 8081 - protocol = "HTTP" - timeout = 3 - healthy_threshold = 3 + path = "/health" + interval = 60 + port = 8081 + protocol = "HTTP" + timeout = 3 + healthy_threshold = 3 unhealthy_threshold = 3 - matcher = "200-299" + matcher = "200-299" } tags = { Environment = "Production" - Type = "ALB Target Group" + Type = "ALB Target Group" } } @@ -1387,34 +1369,32 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-update-tags" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_updateHealthCheck(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 stickiness { - type = "lb_cookie" + type = "lb_cookie" cookie_duration = 10000 } health_check { - path = "/health2" - interval = 30 - port = 8082 - protocol = "HTTPS" - timeout = 4 - healthy_threshold = 4 + path = "/health2" + interval = 30 + port = 8082 + protocol = "HTTPS" + timeout = 4 + healthy_threshold = 4 unhealthy_threshold = 4 - matcher = "200" + matcher = "200" } } @@ -1424,8 +1404,7 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-update-health-check" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_Protocol_Tls(targetGroupName string) string { @@ -1460,20 +1439,19 @@ resource "aws_lb_target_group" "test" { } func testAccAWSLBTargetGroupConfig_typeTCP(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 8082 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 8082 protocol = "TCP" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 health_check { - interval = 10 - port = "traffic-port" - protocol = "TCP" - healthy_threshold = 3 + interval = 10 + port = "traffic-port" + protocol = "TCP" + healthy_threshold = 3 unhealthy_threshold = 3 } @@ -1488,26 +1466,24 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-type-tcp" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_typeTCP_withProxyProtocol(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 8082 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 8082 protocol = "TCP" - vpc_id = "${aws_vpc.test.id}" - - proxy_protocol_v2 = "true" - deregistration_delay = 200 + vpc_id = "${aws_vpc.test.id}" + + proxy_protocol_v2 = "true" + deregistration_delay = 200 health_check { - interval = 10 - port = "traffic-port" - protocol = "TCP" - healthy_threshold = 3 + interval = 10 + port = "traffic-port" + protocol = "TCP" + healthy_threshold = 3 unhealthy_threshold = 3 } @@ -1522,25 +1498,23 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-type-tcp" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_typeTCPInvalidThreshold(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 8082 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 8082 protocol = "TCP" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 health_check { - interval = 10 - port = "traffic-port" - protocol = "TCP" - healthy_threshold = 3 + interval = 10 + port = "traffic-port" + protocol = "TCP" + healthy_threshold = 3 unhealthy_threshold = 4 } @@ -1555,25 +1529,23 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-type-tcp" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_typeTCPThresholdUpdated(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 8082 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 8082 protocol = "TCP" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 health_check { - interval = 10 - port = "traffic-port" - protocol = "TCP" - healthy_threshold = 5 + interval = 10 + port = "traffic-port" + protocol = "TCP" + healthy_threshold = 5 unhealthy_threshold = 5 } @@ -1588,25 +1560,23 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-type-tcp-threshold-updated" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_typeTCPIntervalUpdated(targetGroupName string) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 8082 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 8082 protocol = "TCP" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 health_check { - interval = 30 - port = "traffic-port" - protocol = "TCP" - healthy_threshold = 5 + interval = 30 + port = "traffic-port" + protocol = "TCP" + healthy_threshold = 5 unhealthy_threshold = 5 } @@ -1621,13 +1591,11 @@ resource "aws_vpc" "test" { tags = { Name = "terraform-testacc-lb-target-group-type-tcp-interval-updated" } -} -`, targetGroupName) +}`, targetGroupName) } func testAccAWSLBTargetGroupConfig_typeTCP_HTTPHealthCheck(targetGroupName, path string, threshold int) string { - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { name = "%[1]s" port = 8082 protocol = "TCP" @@ -1651,12 +1619,10 @@ resource "aws_lb_target_group" "test" { resource "aws_vpc" "test" { cidr_block = "10.0.0.0/16" - tags = { Name = "terraform-testacc-lb-target-group-type-tcp-http-health-check" } -} -`, targetGroupName, threshold, path) +}`, targetGroupName, threshold, path) } func testAccAWSLBTargetGroupConfig_stickiness(targetGroupName string, addStickinessBlock bool, enabled bool) string { @@ -1670,24 +1636,25 @@ func testAccAWSLBTargetGroupConfig_stickiness(targetGroupName string, addStickin }`, enabled) } - return fmt.Sprintf(` -resource "aws_lb_target_group" "test" { - name = "%s" - port = 443 + return fmt.Sprintf(`resource "aws_lb_target_group" "test" { + name = "%s" + port = 443 protocol = "HTTPS" - vpc_id = "${aws_vpc.test.id}" + vpc_id = "${aws_vpc.test.id}" deregistration_delay = 200 - %s#_#" health_check { - path = "/health2" - interval = 30 - port = 8082 - protocol = "HTTPS" - timeout = 4 - healthy_threshold = 4 + %s + + health_check { + path = "/health2" + interval = 30 + port = 8082 + protocol = "HTTPS" + timeout = 4 + healthy_threshold = 4 unhealthy_threshold = 4 - matcher = "200" + matcher = "200" } } @@ -1697,8 +1664,7 @@ resource "aws_vpc" "test" { tags = { TestName = "terraform-testacc-lb-target-group-stickiness" } -} -`, targetGroupName, stickinessBlock) +}`, targetGroupName, stickinessBlock) } const testAccAWSLBTargetGroupConfig_namePrefix = `