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