From 04b26818e76b34952af221bed88d7c14be4e9ad5 Mon Sep 17 00:00:00 2001 From: "xiaowei.wang" Date: Wed, 14 Feb 2018 21:16:32 +0100 Subject: [PATCH 1/3] resource/lb_listener_rule: update maximum priority value to 50000 --- aws/resource_aws_lb_listener_rule.go | 6 +++--- website/docs/r/lb_listener_rule.html.markdown | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_lb_listener_rule.go b/aws/resource_aws_lb_listener_rule.go index 020dc7d848d9..48932c6c9e87 100644 --- a/aws/resource_aws_lb_listener_rule.go +++ b/aws/resource_aws_lb_listener_rule.go @@ -154,7 +154,7 @@ func resourceAwsLbListenerRuleRead(d *schema.ResourceData, meta interface{}) err // Rules are evaluated in priority order, from the lowest value to the highest value. The default rule has the lowest priority. if *rule.Priority == "default" { - d.Set("priority", 99999) + d.Set("priority", 50000) } else { if priority, err := strconv.Atoi(*rule.Priority); err != nil { return errwrap.Wrapf("Cannot convert rule priority %q to int: {{err}}", err) @@ -278,8 +278,8 @@ func resourceAwsLbListenerRuleDelete(d *schema.ResourceData, meta interface{}) e func validateAwsLbListenerRulePriority(v interface{}, k string) (ws []string, errors []error) { value := v.(int) - if value < 1 || value > 99999 { - errors = append(errors, fmt.Errorf("%q must be in the range 1-99999", k)) + if value < 1 || value > 50000 { + errors = append(errors, fmt.Errorf("%q must be in the range 1-50000", k)) } return } diff --git a/website/docs/r/lb_listener_rule.html.markdown b/website/docs/r/lb_listener_rule.html.markdown index 3473b123c549..4ba02da7159c 100644 --- a/website/docs/r/lb_listener_rule.html.markdown +++ b/website/docs/r/lb_listener_rule.html.markdown @@ -61,7 +61,7 @@ resource "aws_lb_listener_rule" "host_based_routing" { The following arguments are supported: * `listener_arn` - (Required, Forces New Resource) The ARN of the listener to which to attach the rule. -* `priority` - (Required) The priority for the rule. A listener can't have multiple rules with the same priority. +* `priority` - (Required) The priority for the rule between `1` and `50000`. A listener can't have multiple rules with the same priority. * `action` - (Required) An Action block. Action blocks are documented below. * `condition` - (Required) A Condition block. Condition blocks are documented below. From 1e73a7ffe378dd64bb8b229c6f15b105aad19f62 Mon Sep 17 00:00:00 2001 From: "xiaowei.wang" Date: Thu, 15 Feb 2018 15:24:05 +0100 Subject: [PATCH 2/3] resource/lb_listener_rule: remove custom validation function --- aws/resource_aws_lb_listener_rule.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/aws/resource_aws_lb_listener_rule.go b/aws/resource_aws_lb_listener_rule.go index 48932c6c9e87..03565223492a 100644 --- a/aws/resource_aws_lb_listener_rule.go +++ b/aws/resource_aws_lb_listener_rule.go @@ -38,7 +38,7 @@ func resourceAwsLbbListenerRule() *schema.Resource { Type: schema.TypeInt, Required: true, ForceNew: true, - ValidateFunc: validateAwsLbListenerRulePriority, + ValidateFunc: validateIntegerInRange(1, 50000), }, "action": { Type: schema.TypeList, @@ -276,14 +276,6 @@ func resourceAwsLbListenerRuleDelete(d *schema.ResourceData, meta interface{}) e return nil } -func validateAwsLbListenerRulePriority(v interface{}, k string) (ws []string, errors []error) { - value := v.(int) - if value < 1 || value > 50000 { - errors = append(errors, fmt.Errorf("%q must be in the range 1-50000", k)) - } - return -} - func validateAwsListenerRuleField(v interface{}, k string) (ws []string, errors []error) { value := v.(string) if len(value) > 64 { From 8e33671789a1ff57c0bc832795c500d391d23164 Mon Sep 17 00:00:00 2001 From: "xiaowei.wang" Date: Thu, 15 Feb 2018 17:25:07 +0100 Subject: [PATCH 3/3] resource/lb_listener_rule: avoid breaking change for default rule priority --- aws/resource_aws_lb_listener_rule.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_lb_listener_rule.go b/aws/resource_aws_lb_listener_rule.go index 03565223492a..7fea69f21182 100644 --- a/aws/resource_aws_lb_listener_rule.go +++ b/aws/resource_aws_lb_listener_rule.go @@ -38,7 +38,7 @@ func resourceAwsLbbListenerRule() *schema.Resource { Type: schema.TypeInt, Required: true, ForceNew: true, - ValidateFunc: validateIntegerInRange(1, 50000), + ValidateFunc: validateAwsLbListenerRulePriority, }, "action": { Type: schema.TypeList, @@ -154,10 +154,10 @@ func resourceAwsLbListenerRuleRead(d *schema.ResourceData, meta interface{}) err // Rules are evaluated in priority order, from the lowest value to the highest value. The default rule has the lowest priority. if *rule.Priority == "default" { - d.Set("priority", 50000) + d.Set("priority", 99999) } else { if priority, err := strconv.Atoi(*rule.Priority); err != nil { - return errwrap.Wrapf("Cannot convert rule priority %q to int: {{err}}", err) + return fmt.Errorf("Cannot convert rule priority %q to int: {{err}}", err) } else { d.Set("priority", priority) } @@ -276,6 +276,14 @@ func resourceAwsLbListenerRuleDelete(d *schema.ResourceData, meta interface{}) e return nil } +func validateAwsLbListenerRulePriority(v interface{}, k string) (ws []string, errors []error) { + value := v.(int) + if value < 1 || (value > 50000 && value != 99999) { + errors = append(errors, fmt.Errorf("%q must be in the range 1-50000 for normal rule or 99999 for default rule", k)) + } + return +} + func validateAwsListenerRuleField(v interface{}, k string) (ws []string, errors []error) { value := v.(string) if len(value) > 64 {