GCLOUD_IAM_SERVICE-ACCOUNTS_SET-IAM-POLICY(1)

NAME

gcloud iam service-accounts set-iam-policy - set IAM policy for a service account

SYNOPSIS

gcloud iam service-accounts set-iam-policy SERVICE_ACCOUNT POLICY_FILE [GCLOUD_WIDE_FLAG ...]

DESCRIPTION
This command replaces the existing IAM policy for a service account, given an IAM_ACCOUNT and a file encoded in JSON or YAML that contains the IAM policy. If the given policy file specifies an "etag" value, then the replacement will succeed only if the policy already in place matches that etag. (An etag obtained via $ gcloud iam service-accounts get-iam-policy will prevent the replacement if the policy for the service account has been subsequently updated.) A policy file that does not contain an etag value will replace any existing policy for the service account.

POSITIONAL ARGUMENTS

    SERVICE_ACCOUNT
        The service account whose policy to set. The account should be formatted as an email, like this: my-iam-account@somedomain.com.

    POLICY_FILE
        Path to a local JSON or YAML formatted file containing a valid policy.

GCLOUD WIDE FLAGS
These flags are available to all commands: --account, --configuration, --flatten, --format, --help, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity. Run $ gcloud help for details.

EXAMPLES
The following command will read an IAM policy defined in a JSON file 'policy.json' and set it for a service account with identifier 'my-iam-account@somedomain.com'
    $ gcloud iam service-accounts set-iam-policy \
        my-iam-account@somedomain.com policy.json
See https://cloud.google.com/iam/docs/managing-policies for details of the policy file format and contents.