What is a Service Account? A Service Account is like a "robot account" - it's not meant for human users but rather for applications and services to authenticate and access GCP resources.
Main Uses with Examples:
{
"type": "service_account",
"project_id": "my-project",
"private_key_id": "abc123...",
"client_email": "[email protected]"
}
How to Create:
# In GCP Console
1. Go to IAM & Admin -> Service Accounts
2. Create Service Account
3. Set permissions (like storage read/write)
4. Download key file (JSON format)
Usage Scenarios:
provider "google" {
credentials = file("path/to/service-account.json")
project = "my-project"
region = "us-central1"
}
from google.cloud import storage
client = storage.Client.from_service_account_json('path/to/service-account.json')
Security Best Practices: