diff --git a/.changelog/17204.txt b/.changelog/17204.txt new file mode 100644 index 00000000000..5efb5394576 --- /dev/null +++ b/.changelog/17204.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_lb_cookie_stickiness_policy: Allow zero value for `cookie_expiration_period` +``` diff --git a/aws/resource_aws_lb_cookie_stickiness_policy.go b/aws/resource_aws_lb_cookie_stickiness_policy.go index 17a4460b365..542d687483f 100644 --- a/aws/resource_aws_lb_cookie_stickiness_policy.go +++ b/aws/resource_aws_lb_cookie_stickiness_policy.go @@ -44,7 +44,7 @@ func resourceAwsLBCookieStickinessPolicy() *schema.Resource { Type: schema.TypeInt, Optional: true, ForceNew: true, - ValidateFunc: validation.IntAtLeast(1), + ValidateFunc: validation.IntAtLeast(0), }, }, } diff --git a/aws/resource_aws_lb_cookie_stickiness_policy_test.go b/aws/resource_aws_lb_cookie_stickiness_policy_test.go index ba51e10e711..9a86dedbcb5 100644 --- a/aws/resource_aws_lb_cookie_stickiness_policy_test.go +++ b/aws/resource_aws_lb_cookie_stickiness_policy_test.go @@ -14,6 +14,7 @@ import ( func TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) { lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(5)) + resourceName := "aws_lb_cookie_stickiness_policy.foo" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -22,6 +23,7 @@ func TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) { { Config: testAccLBCookieStickinessPolicyConfig(lbName), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "cookie_expiration_period", "300"), testAccCheckLBCookieStickinessPolicy( "aws_elb.lb", "aws_lb_cookie_stickiness_policy.foo", @@ -31,6 +33,7 @@ func TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) { { Config: testAccLBCookieStickinessPolicyConfigUpdate(lbName), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "cookie_expiration_period", "0"), testAccCheckLBCookieStickinessPolicy( "aws_elb.lb", "aws_lb_cookie_stickiness_policy.foo", @@ -156,14 +159,15 @@ resource "aws_elb" "lb" { } resource "aws_lb_cookie_stickiness_policy" "foo" { - name = "foo-policy" - load_balancer = aws_elb.lb.id - lb_port = 80 + name = "foo-policy" + load_balancer = aws_elb.lb.id + lb_port = 80 + cookie_expiration_period = 300 } `, rName)) } -// Sets the cookie_expiration_period to 300s. +// Sets the cookie_expiration_period to 0s. func testAccLBCookieStickinessPolicyConfigUpdate(rName string) string { return composeConfig(testAccAvailableAZsNoOptInConfig(), fmt.Sprintf(` resource "aws_elb" "lb" { @@ -182,7 +186,7 @@ resource "aws_lb_cookie_stickiness_policy" "foo" { name = "foo-policy" load_balancer = aws_elb.lb.id lb_port = 80 - cookie_expiration_period = 300 + cookie_expiration_period = 0 } `, rName)) }