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 editor
button at the top of the terminal to navigate to your editor. - Create a file with
.sh
extension in the root directory i.e.drata.sh
. - Copy the content of the
gcp-drata-script.sh
from this project and paste it in the newly created file. - Click the
Open terminal
button at the top of the editor to navigate back to your terminal, run the following commands.chmod +x drata.sh
to give it execution permissions../drata.sh
to run the script.
- The prompt
Will the service account connect multiple projects? [y/n]
will appear. Respond withn
if 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.json
file. - In the Drata app, go to the GCP connection drawer and select Upload File to upload the
drata-key-file.json
file. - Select the
Save & Test Connection
button.
- 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 creation
on the🔽 Filter
bar and select the policy. - Click over
📝 MANAGE POLICY
button. - Go to
Policy source
and select theOverride parent's policy
option. - Scroll down a little and open up the
Enforced
rule. - Make sure the
Enforcement
section isOff
. - Click
SET POLICY
to save changes. - Run this script again.