diff --git a/google/resource_compute_instance_iam_test.go b/google/resource_compute_instance_iam_test.go index aeb4724a9ef..e3a67b72ca4 100644 --- a/google/resource_compute_instance_iam_test.go +++ b/google/resource_compute_instance_iam_test.go @@ -130,7 +130,7 @@ func testAccComputeInstanceIamMember_basic(zone, instanceName, roleId string) st zone = "${google_compute_instance.test_vm.zone}" instance_name = "${google_compute_instance.test_vm.name}" role = "%s" - member = "user:admin@hashicorptest.com" + member = "user:Admin@hashicorptest.com" } `, zone, instanceName, roleId) @@ -157,7 +157,7 @@ func testAccComputeInstanceIamPolicy_basic(zone, instanceName, roleId string) st data "google_iam_policy" "foo" { binding { role = "%s" - members = ["user:admin@hashicorptest.com"] + members = ["user:Admin@hashicorptest.com"] } } @@ -194,7 +194,7 @@ func testAccComputeInstanceIamBinding_basic(zone, instanceName, roleId string) s zone = "${google_compute_instance.test_vm.zone}" instance_name = "${google_compute_instance.test_vm.name}" role = "%s" - members = ["user:admin@hashicorptest.com"] + members = ["user:Admin@hashicorptest.com"] } `, zone, instanceName, roleId) @@ -223,7 +223,7 @@ func testAccComputeInstanceIamBinding_update(zone, instanceName, roleId string) zone = "${google_compute_instance.test_vm.zone}" instance_name = "${google_compute_instance.test_vm.name}" role = "%s" - members = ["user:admin@hashicorptest.com", "user:paddy@hashicorp.com"] + members = ["user:Admin@hashicorptest.com", "user:paddy@hashicorp.com"] } `, zone, instanceName, roleId) diff --git a/google/resource_google_project_iam_policy.go b/google/resource_google_project_iam_policy.go index 3f2b78742db..50090ebceaf 100644 --- a/google/resource_google_project_iam_policy.go +++ b/google/resource_google_project_iam_policy.go @@ -6,6 +6,7 @@ import ( "log" "reflect" "sort" + "strings" "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform/helper/schema" @@ -217,6 +218,9 @@ func derefBindings(b []*cloudresourcemanager.Binding) []cloudresourcemanager.Bin for i, v := range b { db[i] = *v + for j, m := range db[i].Members { + db[i].Members[j] = strings.ToLower(m) + } sort.Strings(db[i].Members) } return db diff --git a/google/resource_iam_binding.go b/google/resource_iam_binding.go index ad0225d44b8..1a6cd7ba173 100644 --- a/google/resource_iam_binding.go +++ b/google/resource_iam_binding.go @@ -20,7 +20,11 @@ var iamBindingSchema = map[string]*schema.Schema{ Type: schema.TypeSet, Required: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + DiffSuppressFunc: caseDiffSuppress, + }, + Set: func(v interface{}) int { + return schema.HashString(strings.ToLower(v.(string))) }, }, "etag": { diff --git a/google/resource_iam_member.go b/google/resource_iam_member.go index d1a37544cae..87fcc1293ad 100644 --- a/google/resource_iam_member.go +++ b/google/resource_iam_member.go @@ -17,9 +17,10 @@ var IamMemberBaseSchema = map[string]*schema.Schema{ ForceNew: true, }, "member": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: caseDiffSuppress, }, "etag": { Type: schema.TypeString, @@ -98,7 +99,7 @@ func resourceIamMemberCreate(newUpdaterFunc newResourceIamUpdaterFunc) schema.Cr if err != nil { return err } - d.SetId(updater.GetResourceId() + "/" + p.Role + "/" + p.Members[0]) + d.SetId(updater.GetResourceId() + "/" + p.Role + "/" + strings.ToLower(p.Members[0])) return resourceIamMemberRead(newUpdaterFunc)(d, meta) } } @@ -138,7 +139,7 @@ func resourceIamMemberRead(newUpdaterFunc newResourceIamUpdaterFunc) schema.Read } var member string for _, m := range binding.Members { - if m == eMember.Members[0] { + if strings.ToLower(m) == strings.ToLower(eMember.Members[0]) { member = m } } @@ -179,7 +180,7 @@ func resourceIamMemberDelete(newUpdaterFunc newResourceIamUpdaterFunc) schema.De binding := p.Bindings[bindingToRemove] memberToRemove := -1 for pos, m := range binding.Members { - if m != member.Members[0] { + if strings.ToLower(m) != strings.ToLower(member.Members[0]) { continue } memberToRemove = pos