GCP Authentication in Prowler¶
Prowler for Google Cloud supports multiple authentication methods. To use a specific method, configure the appropriate credentials during execution:
- User Credentials (Application Default Credentials)
- Service Account Key File
- Access Token
- Service Account Impersonation
Required Permissions¶
Prowler for Google Cloud requires the following permissions:
IAM Roles¶
- Reader (
roles/reader
) – Must be granted at the project, folder, or organization level to allow scanning of target projects.
Project-Level Settings¶
At least one project must have the following configurations:
-
Identity and Access Management (IAM) API (
iam.googleapis.com
) – Must be enabled via:- The Google Cloud API UI, or
- The
gcloud
CLI:
-
Service Usage Consumer (
roles/serviceusage.serviceUsageConsumer
) IAM Role – Required for resource scanning. -
Quota Project Setting – Define a quota project using either:
- The
gcloud
CLI: - Setting an environment variable:
- The
Note
Prowler will scan the GCP project associated with the credentials.
Application Default Credentials (User Credentials)¶
This method uses the Google Cloud CLI to authenticate and is suitable for development and testing environments.
Setup Application Default Credentials¶
-
In the GCP Console, click on "Activate Cloud Shell"
-
Click "Authorize Cloud Shell"
-
Run the following command:
- Type
Y
when prompted
- Type
-
Open the authentication URL provided in a browser and select your Google account
-
Follow the steps to obtain the authentication code
-
Paste the authentication code back in Cloud Shell
-
Use
cat <file_name>
to view the temporary credentials file -
Extract the following values for Prowler Cloud/App:
client_id
client_secret
refresh_token
Using with Prowler CLI¶
Once application default credentials are set up, run Prowler directly:
Service Account Key File¶
This method uses a service account with a downloaded key file for authentication.
Create Service Account and Key¶
- Go to the Service Accounts page in the GCP Console
- Click "Create Service Account"
- Fill in the service account details and click "Create and Continue"
- Grant the service account the "Reader" role
- Click "Done"
- Find your service account in the list and click on it
- Go to the "Keys" tab
- Click "Add Key" > "Create new key"
- Select "JSON" and click "Create"
- Save the downloaded key file securely
Using with Prowler CLI¶
Set the GOOGLE_APPLICATION_CREDENTIALS
environment variable:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
prowler gcp --project-ids <project-id>
Access Token¶
For existing access tokens (e.g., generated with gcloud auth print-access-token
), run Prowler with:
export CLOUDSDK_AUTH_ACCESS_TOKEN=$(gcloud auth print-access-token)
prowler gcp --project-ids <project-id>
Note
When using this method, also set the default project explicitly:
Service Account Impersonation¶
To impersonate a GCP service account, use the --impersonate-service-account
argument followed by the service account email:
This command leverages the default credentials to impersonate the specified service account.
Prerequisites for Impersonation¶
The identity running Prowler must have the following permission on the target service account:
roles/iam.serviceAccountTokenCreator
Or the more specific permission:
iam.serviceAccounts.generateAccessToken