From 8898d98d6cb78e49b5bb8283f37c492b5fe1aa9b Mon Sep 17 00:00:00 2001 From: bill-rich Date: Wed, 20 Jan 2021 17:04:07 -0800 Subject: [PATCH 1/5] Allow zero value for cookie_expiration_period --- aws/resource_aws_lb_cookie_stickiness_policy.go | 2 +- aws/resource_aws_lb_cookie_stickiness_policy_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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..e45b27f941b 100644 --- a/aws/resource_aws_lb_cookie_stickiness_policy_test.go +++ b/aws/resource_aws_lb_cookie_stickiness_policy_test.go @@ -159,6 +159,7 @@ resource "aws_lb_cookie_stickiness_policy" "foo" { name = "foo-policy" load_balancer = aws_elb.lb.id lb_port = 80 + cookie_expiration_period = 0 } `, rName)) } From 5387f154a6d303683009660e542d68e64fc4d442 Mon Sep 17 00:00:00 2001 From: bill-rich Date: Wed, 20 Jan 2021 20:37:17 -0800 Subject: [PATCH 2/5] Switch cookie expiration values --- aws/resource_aws_lb_cookie_stickiness_policy_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_lb_cookie_stickiness_policy_test.go b/aws/resource_aws_lb_cookie_stickiness_policy_test.go index e45b27f941b..093e954b7a1 100644 --- a/aws/resource_aws_lb_cookie_stickiness_policy_test.go +++ b/aws/resource_aws_lb_cookie_stickiness_policy_test.go @@ -159,7 +159,7 @@ resource "aws_lb_cookie_stickiness_policy" "foo" { name = "foo-policy" load_balancer = aws_elb.lb.id lb_port = 80 - cookie_expiration_period = 0 + cookie_expiration_period = 300 } `, rName)) } @@ -183,7 +183,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)) } From 627a620fdc0202035df5be56dd38665d56399651 Mon Sep 17 00:00:00 2001 From: bill-rich Date: Thu, 21 Jan 2021 17:38:50 -0800 Subject: [PATCH 3/5] Fix test config formatting --- aws/resource_aws_lb_cookie_stickiness_policy_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_lb_cookie_stickiness_policy_test.go b/aws/resource_aws_lb_cookie_stickiness_policy_test.go index 093e954b7a1..c2f46b8acce 100644 --- a/aws/resource_aws_lb_cookie_stickiness_policy_test.go +++ b/aws/resource_aws_lb_cookie_stickiness_policy_test.go @@ -156,9 +156,9 @@ 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)) From fcb04278ea59ea2b45c8969488531dffcddf2e58 Mon Sep 17 00:00:00 2001 From: bill-rich Date: Fri, 5 Feb 2021 09:23:00 -0800 Subject: [PATCH 4/5] Add acceptance test checks and comment --- aws/resource_aws_lb_cookie_stickiness_policy_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_lb_cookie_stickiness_policy_test.go b/aws/resource_aws_lb_cookie_stickiness_policy_test.go index c2f46b8acce..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", @@ -164,7 +167,7 @@ resource "aws_lb_cookie_stickiness_policy" "foo" { `, 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" { From a8572eaacfd049657acdadaeb0423fa01dfaea0b Mon Sep 17 00:00:00 2001 From: bill-rich Date: Thu, 11 Feb 2021 16:57:49 -0800 Subject: [PATCH 5/5] Add changelog entry --- .changelog/17204.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/17204.txt 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` +```