Deployed model is ready to serve the request for predictions. While sending data and model details for predictions users should also be authenticated. In these scenarios user GCP account details cannot be used for authentication, service account is needed. Follow below steps for service account creation. Open IAM and admin and follow steps as shown in Figure 2.30:
Step 1: Service account creation

- Select service accounts under IAM and admin section.
- Click on Create service account.
Step 2: Service account details
Follow steps shown in Figure 2.31 to add account details:

Figure 2.31: Service account details
- Provide name for the service account.
- Provide service account ID.
- Provide description for the service account.
- Click on Create and continue.
Changing the access to the service account is not required for this exercise.
Step 3: Assigning roles for the service account
During the process of service account creation let us also grant the access to certain roles needed for this service account. Granting these roles are important since we will use the same service account for custom model building, pipelines, and so on. Follow steps shown in the Figure 2.32 to grant roles. (It is an optional step and can be done as and when needed as well).

Figure 2.32: Grant AI platform access to service account
- Click on select role.
- Select AI Platform under actions.
- Select AI platform admin.
Similarly, add few other roles belonging to cloud storage and vertex AI as displayed in the Figure 2.33:

Figure 2.33: Grant other access to service account
Step 4: Service account manage keys
Once service account is created, users need to create keys. Follow steps shown in Figure 2.34 and Figure 2.35 to create keys:

Figure 2.34: Service account manage keys
- Service account is now created.
- Click on the actions of the created service account and click on manage keys.
Step 4: Service account add keys

Figure 2.35: Service account key creation
- Click on ADD KEY and choose create new key.
A Pop up will provide options to create key in json/P12 format. Choose json format and .json file will be downloaded.
Note: Users needs to provide full path of the json file for authentication in the python code. We can use the same key for next chapter also.