provider/aws: Fix issue with LB Cookie Stickiness and empty expiration period

This commit is contained in:
clint shryock 2015-11-13 10:34:15 -06:00
parent 536ba76b21
commit b81f9a9c52
2 changed files with 9 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package aws
import (
"fmt"
"log"
"strings"
"github.com/aws/aws-sdk-go/aws"
@ -51,11 +52,15 @@ func resourceAwsLBCookieStickinessPolicyCreate(d *schema.ResourceData, meta inte
// Provision the LBStickinessPolicy
lbspOpts := &elb.CreateLBCookieStickinessPolicyInput{
CookieExpirationPeriod: aws.Int64(int64(d.Get("cookie_expiration_period").(int))),
LoadBalancerName: aws.String(d.Get("load_balancer").(string)),
PolicyName: aws.String(d.Get("name").(string)),
LoadBalancerName: aws.String(d.Get("load_balancer").(string)),
PolicyName: aws.String(d.Get("name").(string)),
}
if v := d.Get("cookie_expiration_period").(int); v > 0 {
lbspOpts.CookieExpirationPeriod = aws.Int64(int64(v))
}
log.Printf("[DEBUG] LB Cookie Stickiness Policy opts: %#v", lbspOpts)
if _, err := elbconn.CreateLBCookieStickinessPolicy(lbspOpts); err != nil {
return fmt.Errorf("Error creating LBCookieStickinessPolicy: %s", err)
}
@ -66,6 +71,7 @@ func resourceAwsLBCookieStickinessPolicyCreate(d *schema.ResourceData, meta inte
PolicyNames: []*string{aws.String(d.Get("name").(string))},
}
log.Printf("[DEBUG] LB Cookie Stickiness create configuration: %#v", setLoadBalancerOpts)
if _, err := elbconn.SetLoadBalancerPoliciesOfListener(setLoadBalancerOpts); err != nil {
return fmt.Errorf("Error setting LBCookieStickinessPolicy: %s", err)
}

View File

@ -94,7 +94,6 @@ resource "aws_lb_cookie_stickiness_policy" "foo" {
name = "foo-policy"
load_balancer = "${aws_elb.lb.id}"
lb_port = 80
cookie_expiration_period = 600
}
`