diff --git a/google/data_source_google_iam_policy.go b/google/data_source_google_iam_policy.go index 637d77526d5..760f629670c 100644 --- a/google/data_source_google_iam_policy.go +++ b/google/data_source_google_iam_policy.go @@ -2,11 +2,13 @@ package google import ( "encoding/json" + "regexp" "sort" "strconv" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "google.golang.org/api/cloudresourcemanager/v1" ) @@ -38,8 +40,11 @@ func dataSourceGoogleIamPolicy() *schema.Resource { "members": { Type: schema.TypeSet, Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Set: schema.HashString, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringDoesNotMatch(regexp.MustCompile("^deleted:"), "Terraform does not support IAM policies for deleted principals"), + }, + Set: schema.HashString, }, }, }, diff --git a/google/resource_iam_binding.go b/google/resource_iam_binding.go index 52be5263ec2..b98d25a09b6 100644 --- a/google/resource_iam_binding.go +++ b/google/resource_iam_binding.go @@ -4,9 +4,11 @@ import ( "errors" "fmt" "log" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "google.golang.org/api/cloudresourcemanager/v1" ) @@ -22,6 +24,7 @@ var iamBindingSchema = map[string]*schema.Schema{ Elem: &schema.Schema{ Type: schema.TypeString, DiffSuppressFunc: caseDiffSuppress, + ValidateFunc: validation.StringDoesNotMatch(regexp.MustCompile("^deleted:"), "Terraform does not support IAM bindings for deleted principals"), }, Set: func(v interface{}) int { return schema.HashString(strings.ToLower(v.(string))) diff --git a/google/resource_iam_member.go b/google/resource_iam_member.go index 0a056206be4..06e8f5afcc0 100644 --- a/google/resource_iam_member.go +++ b/google/resource_iam_member.go @@ -4,9 +4,11 @@ import ( "errors" "fmt" "log" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "google.golang.org/api/cloudresourcemanager/v1" ) @@ -21,6 +23,7 @@ var IamMemberBaseSchema = map[string]*schema.Schema{ Required: true, ForceNew: true, DiffSuppressFunc: caseDiffSuppress, + ValidateFunc: validation.StringDoesNotMatch(regexp.MustCompile("^deleted:"), "Terraform does not support IAM members for deleted principals"), }, "etag": { Type: schema.TypeString,