Skip to content

Commit

Permalink
resource/lb_listener_rule: avoid breaking change for default rule pri…
Browse files Browse the repository at this point in the history
…ority
  • Loading branch information
xiaowei.wang committed Feb 16, 2018
1 parent 1e73a7f commit 8e33671
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions aws/resource_aws_lb_listener_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8e33671

Please sign in to comment.