Connect GCP
Create a service account with the required roles and connect your GCP project to VikingCloud.
This guide shows you how to create a GCP service account with the roles VikingCloud needs to scan your project. Choose either the Console (GUI) method or the CLI method below.
Required Roles
| Role | Purpose |
|---|---|
roles/viewer | Resource discovery — enumerate all project resources |
roles/artifactregistry.reader | Container scanning — pull images from Artifact Registry |
roles/compute.storageAdmin | VM scanning — create and delete snapshots and disks |
roles/compute.instanceAdmin.v1 | VM scanning — create and delete ephemeral scanner VMs |
Method 1: Google Cloud Console (GUI)
Step 1: Create a Service Account
- Go to the Google Cloud Console
- Select your project from the project dropdown
- Navigate to IAM & Admin > Service Accounts
- Click Create Service Account
- Enter:
- Name:
vikingcloud-platform-sa - Description:
VikingCloud Platform Scanner
- Name:
- Click Create and Continue
Step 2: Assign Roles
- Click Add Another Role and add each of the following roles:
ViewerArtifact Registry ReaderCompute Storage AdminCompute Instance Admin (v1)
- Click Continue, then Done
Step 3: Create a JSON Key
- Click on the service account you just created
- Go to the Keys tab
- Click Add Key > Create new key
- Select JSON format
- Click Create — the key file downloads automatically
- Store this file securely — you will upload it to VikingCloud
Step 4: Enter Credentials in VikingCloud
- In VikingCloud, go to Settings > Connections
- Click Add Connection and select GCP
- Upload the JSON key file from Step 3
- Click Save
Method 2: gcloud CLI
Prerequisites
- Google Cloud SDK installed and authenticated
Step 1: Create the Service Account and Assign Roles
# Set your project ID
PROJECT_ID=$(gcloud config get-value project)
# Create the service account
gcloud iam service-accounts create vikingcloud-platform-sa \
--display-name="VikingCloud Platform Scanner"
SA_EMAIL="vikingcloud-platform-sa@${PROJECT_ID}.iam.gserviceaccount.com"
# Grant Viewer role (resource discovery)
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/viewer"
# Grant Artifact Registry Reader (container scanning)
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/artifactregistry.reader"
# Grant Compute Storage Admin (VM scanning — snapshots and disks)
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/compute.storageAdmin"
# Grant Compute Instance Admin (VM scanning — scanner VMs)
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${SA_EMAIL}" \
--role="roles/compute.instanceAdmin.v1"
# Create the JSON key file
gcloud iam service-accounts keys create vikingcloud-key.json \
--iam-account=${SA_EMAIL}
echo "Key file created: vikingcloud-key.json"
Step 2: Enter Credentials in VikingCloud
Upload the vikingcloud-key.json file in VikingCloud under Settings > Connections > Add Connection > GCP.
Verification
Verify the service account has all required roles:
gcloud projects get-iam-policy ${PROJECT_ID} \
--flatten="bindings[].members" \
--filter="bindings.members:${SA_EMAIL}" \
--format="table(bindings.role)"
Expected output:
ROLE roles/artifactregistry.reader roles/compute.instanceAdmin.v1 roles/compute.storageAdmin roles/viewer
Troubleshooting
Permission Denied Errors
Check that all roles are assigned:
gcloud projects get-iam-policy $(gcloud config get-value project) \ --flatten="bindings[].members" \ --filter="bindings.members:vikingcloud-platform-sa@"
No Container Images Found
Ensure your container images are stored in Artifact Registry (not the legacy Container Registry). VikingCloud scans Artifact Registry repositories.
Security Notes
- Scoped by tags: All VikingCloud-created resources (scanner VMs, snapshots, disks) are tagged with
owner=vikingcloud - Ephemeral resources: Scanner VMs and snapshots exist only during scans, typically under 10 minutes
- No network access: Scanner VMs have no external IP and cannot access the internet
- Read-only data access: VikingCloud reads disk data via snapshots but never modifies your VMs