Creating and Managing GCP Service Accounts

45 minutes
  • 6 Learning Objectives

About this Hands-on Lab

Unlike standard IAM member accounts, service accounts are used by applications, services, or VM instances and not people. Nonetheless, the two types of accounts share many of the same features, including the ability to be assigned pre-defined or custom roles. But, of course, there are differences such as the technique for associating a VM instance with a service account.

In this hands-on lab, you’ll work with service accounts in a variety of ways: creating, editing, disabling, enabling, assigning IAM roles, and attaching a service account to a VM instance.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a service account.
  1. From the Google Cloud console’s main navigation, choose IAM & admin > Service accounts.
  2. Click Create Service Account.
  3. On the Create Service Account page, enter a name such as App Team Service Account.
  4. Click Create.
  5. On the next page, leave the Service account permissions as their default settings and click Continue.
  6. On the next page, leave the Users access fields blank.
  7. Click Create Key.
  8. On the Create Key panel, set the Key Type to JSON and click Create.
  9. Save the generated key to the desired location on your local system and, in the dialog, click Close.
  10. Click Done.
Edit the service account.
  1. From the Service Accounts page, review the created account entry.
  2. Select the associated Actions icon and choose Edit.
  3. In the Description field, enter the following: For development only.
  4. Click Save.
Disable and enable service account.
  1. From the Service Accounts page, review the revised account entry.
  2. Select the associated Actions icon and choose Disable.
  3. In the dialog that appears, click Disable.
  4. Note the revised Status icon.
  5. Select the associated Actions icon and choose Enable.
  6. In the dialog that appears, click Enable.
  7. Note the revised Status icon.
Assign IAM roles to service account.
  1. From the Service Accounts page, copy the email address for the new service account.
  2. From the IAM navigation, choose IAM.
  3. Click Add Member.
  4. In the Add Members panel, paste the copied email address into the New Members field.
  5. In the Select a role field, choose Viewer.
  6. Click Save.
Attach the service account to a VM instance.
  1. From the main Google Cloud navigation, choose Compute Engine > VM Instances.
  2. Choose Create Instance.
  3. Leave all the values at their defaults.
  4. In the Identity and API Access section, select the Service account list and choose the App Team Service Account entry.
  5. Click Create.
Delete the service account.
  1. From the Google Cloud console’s main navigation, choose IAM & admin > Service accounts.
  2. Select the associated Actions icon and choose Delete.
  3. In the dialog that appears, click Delete.

Additional Resources

As your team begins to build their new app, you've been asked to take ownership of the required IAM service account. You'll need to:

  1. Create a new account.
  2. Understand how to edit the account once it's been created.
  3. Figure out how to disable and re-enable the account if necessary.
  4. Assign an IAM role to the account after it has been created.
  5. Attach the service account to a virtual machine.
  6. Delete the account as it should no longer be needed.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?