• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

GCP Change VM Service Account

June 1, 2023

Here’s how to change a VM’s service account in GCP

#!/bin/bash
read -p "project       : " project
read -p "instance      : " instance
read -p "srvAcct email : " serviceaccount
# stop instance
gcloud compute instances stop $instance --project $project 
# change service account
gcloud compute instances set-service-account $instance --service-account $serviceaccount --scopes cloud-platform --project $project 
# start instance 
gcloud compute instances start $instance --project $project

#!/bin/bash read -p "project : " project read -p "instance : " instance read -p "srvAcct email : " serviceaccount # stop instance gcloud compute instances stop $instance --project $project # change service account gcloud compute instances set-service-account $instance --service-account $serviceaccount --scopes cloud-platform --project $project # start instance gcloud compute instances start $instance --project $project

Filed Under: Cloud Tagged With: change, gcp, service account, vm

  • Home
  • About
  • Search

Copyright © 2023