Skip to content

Commit

Permalink
Merge pull request #4032 from appilon/elbv2-suppress-attributes
Browse files Browse the repository at this point in the history
resource/aws_lb: suppress diff for attributes incorrect lb types
  • Loading branch information
bflad authored Apr 4, 2018
2 parents 68b28d9 + 2e82450 commit deacde8
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions aws/resource_aws_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,29 @@ func resourceAwsLb() *schema.Resource {
},

"access_logs": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
DiffSuppressFunc: suppressIfLBType("network"),
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"bucket": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: suppressIfLBType("network"),
},
"prefix": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: suppressIfLBType("network"),
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Type: schema.TypeBool,
Optional: true,
Computed: true,
DiffSuppressFunc: suppressIfLBType("network"),
},
},
},
Expand All @@ -153,21 +157,24 @@ func resourceAwsLb() *schema.Resource {
},

"idle_timeout": {
Type: schema.TypeInt,
Optional: true,
Default: 60,
Type: schema.TypeInt,
Optional: true,
Default: 60,
DiffSuppressFunc: suppressIfLBType("network"),
},

"enable_cross_zone_load_balancing": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Type: schema.TypeBool,
Optional: true,
Default: false,
DiffSuppressFunc: suppressIfLBType("application"),
},

"enable_http2": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Type: schema.TypeBool,
Optional: true,
Default: true,
DiffSuppressFunc: suppressIfLBType("network"),
},

"ip_address_type": {
Expand Down Expand Up @@ -196,6 +203,12 @@ func resourceAwsLb() *schema.Resource {
}
}

func suppressIfLBType(t string) schema.SchemaDiffSuppressFunc {
return func(k string, old string, new string, d *schema.ResourceData) bool {
return d.Get("load_balancer_type").(string) == t
}
}

func resourceAwsLbCreate(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbv2conn

Expand Down

0 comments on commit deacde8

Please sign in to comment.