I was playing with an IAM policy which looks like as below,
{
"bindings": [
{
"members": [
"user:[email protected]"
],
"role": "projects/PROJECT_ID/roles/CUSTOM_ROLE",
"condition": {
"title": "Bucket reader condition example",
"description": "Grants role to user [email protected] for the specific condition.",
"expression":
"resource.name == \"projects/PROJECT_ID/locations/us-central1/buckets/LOG_BUCKET_ID/views/VIEW_ID\""
}
}
],
}
The custom role has only permissions related to the GCP pre-defined role "roles/logging.viewAccessor".
The gcloud command that I executed was, gcloud projects set-iam-policy PROJECT_ID viewPolicy.jsonn
I applied this policy and accidentally revoked all other users/service accounts access including owner as well. How do I get back the access, please suggest.
If your project is under an organization, the Organization admin can give project Owner roles back to the user and service accounts. Else, your only option is to contact Google Cloud Support.
FYI [1],
[1]. https://www.reddit.com/r/Terraform/comments/xs3xhi/locked_myself_out_of_project/