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 IAM-ACCOUNT POLICY-FILE [GLOBAL-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

    IAM-ACCOUNT
        The service account whose policy to set.

    POLICY-FILE
        Path to a local JSON or YAML formatted file containing a valid policy.

GLOBAL FLAGS
Run $ gcloud help for a description of flags available to all commands.

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.