diff --git a/google-beta/resource_compute_firewall.go b/google-beta/resource_compute_firewall.go index e92ceafa77..d58e47ce52 100644 --- a/google-beta/resource_compute_firewall.go +++ b/google-beta/resource_compute_firewall.go @@ -21,6 +21,7 @@ import ( "reflect" "sort" "strconv" + "strings" "time" "github.com/hashicorp/terraform/helper/hashcode" @@ -32,7 +33,7 @@ import ( func resourceComputeFirewallRuleHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%s-", m["protocol"].(string))) + buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["protocol"].(string)))) // We need to make sure to sort the strings below so that we always // generate the same hash code no matter what is in the set. @@ -48,6 +49,13 @@ func resourceComputeFirewallRuleHash(v interface{}) int { return hashcode.String(buf.String()) } +func compareCaseInsensitive(k, old, new string, d *schema.ResourceData) bool { + if strings.ToLower(old) == strings.ToLower(new) { + return true + } + return false +} + func resourceComputeFirewall() *schema.Resource { return &schema.Resource{ Create: resourceComputeFirewallCreate, @@ -199,8 +207,9 @@ func computeFirewallAllowSchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "protocol": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: compareCaseInsensitive, }, "ports": { Type: schema.TypeList, @@ -217,8 +226,9 @@ func computeFirewallDenySchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "protocol": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: compareCaseInsensitive, }, "ports": { Type: schema.TypeList,