Your security team mandates a nightly backup of the IAM policy for the project named "prod-analytics" so it can be checked into version control. You will run the task from a Cloud Shell session and need the policy saved locally as JSON. Which gcloud command accomplishes this in a single step?
gcloud iam service-accounts get-iam-policy prod-analytics --format=json > prod-analytics-iam.json
gcloud iam roles describe prod-analytics --format=json > prod-analytics-iam.json
The gcloud projects get-iam-policy command retrieves the entire IAM policy that is attached to a project. Adding the --format=json flag outputs the policy in JSON, and standard shell redirection (>) writes the result to a file. The other commands either inspect roles, describe the project without returning its IAM policy, or target service-account policies, so they do not capture the project-level IAM policy that must be backed up.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is an IAM policy in GCP?
Open an interactive chat with Bash
What does the gcloud projects get-iam-policy command do?
Open an interactive chat with Bash
How can you save the IAM policy as a local file?
Open an interactive chat with Bash
What is an IAM policy in GCP?
Open an interactive chat with Bash
How does the 'gcloud projects get-iam-policy' command work?
Open an interactive chat with Bash
Why would you save an IAM policy to JSON format?
Open an interactive chat with Bash
GCP Associate Cloud Engineer
Configuring access and security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .