-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add new attribute slow_start to aws_lb_target_group #4661
Changes from all commits
9ce06f9
004b014
bf285ee
0a0f055
5ad9339
5430ab3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ func TestAccAWSALBTargetGroup_basic(t *testing.T) { | |
resource.TestCheckResourceAttr("aws_alb_target_group.test", "protocol", "HTTPS"), | ||
resource.TestCheckResourceAttrSet("aws_alb_target_group.test", "vpc_id"), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "deregistration_delay", "200"), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "slow_start", "0"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need to check |
||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "target_type", "instance"), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "stickiness.#", "1"), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "stickiness.0.enabled", "true"), | ||
|
@@ -415,6 +416,34 @@ func TestAccAWSALBTargetGroup_updateSticknessEnabled(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSALBTargetGroup_setAndUpdateSlowStart(t *testing.T) { | ||
var before, after elbv2.TargetGroup | ||
targetGroupName := fmt.Sprintf("test-target-group-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
IDRefreshName: "aws_alb_target_group.test", | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSALBTargetGroupDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSALBTargetGroupConfig_updateSlowStart(targetGroupName, 30), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckAWSALBTargetGroupExists("aws_alb_target_group.test", &before), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "slow_start", "30"), | ||
), | ||
}, | ||
{ | ||
Config: testAccAWSALBTargetGroupConfig_updateSlowStart(targetGroupName, 60), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckAWSALBTargetGroupExists("aws_alb_target_group.test", &after), | ||
resource.TestCheckResourceAttr("aws_alb_target_group.test", "slow_start", "60"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSALBTargetGroupExists(n string, res *elbv2.TargetGroup) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
|
@@ -757,6 +786,46 @@ resource "aws_vpc" "test" { | |
}`, targetGroupName, stickinessBlock) | ||
} | ||
|
||
func testAccAWSALBTargetGroupConfig_updateSlowStart(targetGroupName string, slowStartDuration int) string { | ||
return fmt.Sprintf(`resource "aws_alb_target_group" "test" { | ||
name = "%s" | ||
port = 443 | ||
protocol = "HTTP" | ||
vpc_id = "${aws_vpc.test.id}" | ||
|
||
deregistration_delay = 200 | ||
slow_start = %d | ||
|
||
stickiness { | ||
type = "lb_cookie" | ||
cookie_duration = 10000 | ||
} | ||
|
||
health_check { | ||
path = "/health" | ||
interval = 60 | ||
port = 8081 | ||
protocol = "HTTP" | ||
timeout = 3 | ||
healthy_threshold = 3 | ||
unhealthy_threshold = 3 | ||
matcher = "200-299" | ||
} | ||
|
||
tags { | ||
TestName = "TestAccAWSALBTargetGroup_SlowStart" | ||
} | ||
} | ||
|
||
resource "aws_vpc" "test" { | ||
cidr_block = "10.0.0.0/16" | ||
|
||
tags { | ||
Name = "terraform-testacc-alb-target-group-slowstart" | ||
} | ||
}`, targetGroupName, slowStartDuration) | ||
} | ||
|
||
const testAccAWSALBTargetGroupConfig_namePrefix = ` | ||
resource "aws_alb_target_group" "test" { | ||
name_prefix = "tf-" | ||
|
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 data source testing is failing because
d.Set("slow_start", ...)
is never called in the resource read function. This would normally be caught in the resource acceptance testing with aTestCase
that callsImportStateVerify: true
.