Shell script to create the Drata Read Only service account.
The following steps demonstrate how to connect GCP in Drata when using this script.
- Navigate to the Cloud Shell terminal in your GCP account using the following link: https://console.cloud.google.com/welcome?cloudshell=true.
- Click the
Open editorbutton at the top of the terminal to navigate to your editor. - Create a file with
.shextension in the root directory i.e.drata.sh. - Copy the content of the
gcp-drata-script.shfrom this project and paste it in the newly created file. - Click the
Open terminalbutton at the top of the editor to navigate back to your terminal, run the following commands.chmod +x drata.shto give it execution permissions../drata.shto run the script.
- The prompt
Will the service account connect multiple projects? [y/n]will appear. Respond withnif it is desired that the service account should only be added to a single project in your organization. - After the process finishes, navigate back to your editor and download the
drata-key-file.jsonfile. - In the Drata app, go to the GCP connection drawer and select Upload File to upload the
drata-key-file.jsonfile. - Select the
Save & Test Connectionbutton.
- Fixing
FAILED_PRECONDITION: Key creation is not allowed on this service account (type: constraints/iam.disableServiceAccountKeyCreation)issue.- Go to the IAM Organization Policies page.
- Make sure the project where the service account will be stored is selected (top left in the console).
- Type
Disable service account key creationon the🔽 Filterbar and select the policy. - Click over
📝 MANAGE POLICYbutton. - Go to
Policy sourceand select theOverride parent's policyoption. - Scroll down a little and open up the
Enforcedrule. - Make sure the
Enforcementsection isOff. - Click
SET POLICYto save changes. - Run this script again.