Configuring Deployment User/Role in GCP
Overview
This guide will help you set up a Service Account in Google Cloud Platform (GCP) that Terraform can use to deploy infrastructure changes. By this stage, you should already have a GCP project ready for deployment.
Creating and Configuring a Service Account
-
Log in to your GCP account.
-
Navigate to the IAM & Admin section and select Service Accounts from the menu.
-
Click Create Service Account named
terraform-deployer
. -
Enter a Service Account Name and optionally a description. Click Create and Continue.
-
Under Grant this service account access to the project, add the following roles:
- Editor
- Project IAM Admin
- Role Administrator
- Secret Manager Admin
- Secret Manager Secret Accessor
-
Under Grant users access to this service account, leave it empty and click Done.
-
Once the service account is created, locate it in the list, click the More Actions menu (three dots), and select Manage Keys.
-
Click Add Key, then select Create New Key. Choose the JSON key type and click Create.
-
Save the downloaded key file in a secure location. This file contains the credentials needed for Terraform.
With these steps completed, your GCP Service Account is set up and ready to be used for Terraform deployments.