Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_lb: suppress diff for attributes incorrect lb types #4032

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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