GcpIntermediate

GCP Security Services: Comprehensive Security Controls

9 min read

TL;DR

Master Google Cloud's security services. Learn about Identity and Access Management (IAM), Cloud KMS, Security Command Center, Cloud Armor, and best practices for securing your cloud infrastructure.

GCP Security Services: Comprehensive Security Controls

Executive Summary

Google Cloud security is layered: identity (Cloud IAM, organisation policies) decides who can act, encryption (default at rest, Cloud KMS where you need control) protects data, network controls (VPC firewall rules, VPC Service Controls, Cloud Armor) constrain where data can move, and detection services (Security Command Center, Cloud Audit Logs) tell you when something is wrong. This guide explains how the layers fit and where teams usually leave gaps — over-broad roles, downloaded service account keys, public storage, and perimeters that were planned but never enforced. After reading it, you should be able to audit a GCP estate against a sensible baseline and know which control addresses which risk.

Why This Matters

Most cloud breaches are configuration stories, not cryptography stories: a bucket made public for a demo, a service account with project-wide Editor that ships in a container image, an ex-employee whose access was never reviewed. The blast radius of each is set by decisions made long before the incident — how roles were scoped, whether keys exist to steal, whether a perimeter would have stopped the data leaving. GCP gives you strong defaults (encryption at rest and in transit, audit logging, private-by-default services in recent years), but identity and data-movement controls are opt-in disciplines. The work in this guide is unglamorous and is precisely where real risk lives.

Core Concepts

Identity: IAM Done Deliberately

Cloud IAM grants a member a role on a resource, inherited down the organisation, folder, and project hierarchy. The operating rules are few and strict: grant to groups rather than individuals, prefer predefined roles, write custom roles only when a predefined one is genuinely too broad, and never use the basic roles (Owner, Editor, Viewer) for day-to-day work — Editor in particular grants write access to most services in a project. Service accounts are identities for workloads; give each workload its own, scoped to what it needs:

# Create service account
gcloud iam service-accounts create my-sa \
  --display-name="My Service Account"

# Assign roles
gcloud projects add-iam-policy-binding my-project \
  --member="serviceAccount:my-sa@my-project.iam.gserviceaccount.com" \
  --role="roles/storage.objectViewer"

The most consequential habit is avoiding downloaded service account keys. A key is a bearer credential that works from anywhere until revoked; attached service accounts, Workload Identity for GKE, and workload identity federation for external systems all provide credentials without a file to leak. Where keys are unavoidable, inventory them, rotate them, and alert on their use from unexpected networks. Organisation policy constraints add guardrails above IAM — for example, enforcing uniform bucket-level access, disabling serial port access, or restricting which services can create external IPs — so a careless grant cannot produce a dangerous configuration in the first place:

# org-policy.yaml
constraints:
  - constraint: "constraints/compute.disableSerialPortAccess"
    booleanPolicy:
      enforced: true
  - constraint: "constraints/storage.uniformBucketLevelAccess"
    booleanPolicy:
      enforced: true

Encryption and Key Management

Google encrypts data at rest and in transit by default with Google-managed keys; for many estates that is sufficient. Cloud KMS earns its place when you need control: customer-managed encryption keys (CMEK) for rotation policy, revocation as an incident lever, separation of duties between data owners and key administrators, or compliance requirements that name key custody. Keys live in key rings, organised by location:

# Create key ring
gcloud kms keyrings create my-keyring \
  --location=global

# Create encryption key
gcloud kms keys create my-key \
  --keyring=my-keyring \
  --location=global \
  --purpose=encryption \
  --rotation-period=90d \
  --next-rotation-time=2024-06-01T12:00:00Z

Application-level envelope encryption through the KMS API suits data that must be encrypted before it reaches any Google service:

# encryption.py
from google.cloud import kms

def encrypt_data(project_id, location_id, keyring_id, key_id, plaintext):
    """Encrypt data using Cloud KMS."""
    client = kms.KeyManagementServiceClient()
    key_name = client.crypto_key_path(project_id, location_id, 
                                    keyring_id, key_id)
    
    encrypt_response = client.encrypt(
        request={
            'name': key_name,
            'plaintext': plaintext.encode('utf-8')
        }
    )
    return encrypt_response.ciphertext

Understand the revocation trade before you rely on it: disabling a key renders everything it protects unreadable, including to you — it is an incident-response lever and a self-inflicted outage in the same button. Secret Manager, not KMS, is where application secrets belong; KMS protects keys, Secret Manager stores and versions the secrets themselves with IAM-gated access.

Finding Sensitive Data: Cloud DLP

Sensitive data discovery is the prerequisite for protecting it. Cloud DLP (now part of Sensitive Data Protection) inspects storage and text for defined info types — names, card numbers, credentials — and can de-identify findings by masking, redaction, or tokenisation:

# dlp_inspection.py
from google.cloud import dlp_v2

def inspect_string(project_id, text_content, info_types):
    """Inspect string for sensitive data."""
    client = dlp_v2.DlpServiceClient()
    parent = f"projects/{project_id}/locations/global"

    inspect_config = {
        "info_types": [{"name": info_type} for info_type in info_types]
    }

    item = {"value": text_content}

    response = client.inspect_content(
        request={
            "parent": parent,
            "inspect_config": inspect_config,
            "item": item
        }
    )
    return response.result

Run discovery scans against BigQuery and Cloud Storage before an auditor does, and treat the first scan's results as a remediation backlog, not a surprise.

Perimeters: VPC Service Controls

IAM answers "who may access this"; VPC Service Controls answer "from where, and to where" — a perimeter around services such as Cloud Storage and BigQuery that blocks data exfiltration to outside projects and access from outside networks, even with valid credentials. Access levels define the trusted contexts (corporate IP ranges, device conditions) allowed to cross the perimeter. This is the control that converts a stolen credential from a data breach into a failed API call, and it is correspondingly the control most likely to break legitimate workflows when first enforced — roll it out in dry-run mode, read the violation logs, and only then enforce.

Edge and Network Controls

Cloud Armor is the web-facing layer: security policies attached to load balancer backends with IP allow/deny lists, rate limiting, and managed WAF rules:

# Create WAF policy
gcloud compute security-policies create waf-policy \
  --description="WAF security policy"

# Add WAF rules
gcloud compute security-policies rules create 1000 \
  --security-policy=waf-policy \
  --expression="evaluatePreconfiguredExpr('xss')" \
  --action=deny-403 \
  --description="Block XSS attacks"

VPC firewall rules and hierarchical firewall policies do the network-layer work inside the estate. Neither replaces application authentication — they reduce who can reach the door, not who can walk through it.

Detection: SCC and Audit Logs

Security Command Center aggregates findings — misconfigurations, exposed resources, vulnerabilities from its scanners, and third-party sources — into one triage queue; its value depends entirely on someone working the queue. Cloud Audit Logs record admin activity and, when enabled, data access; export them to a separate project or organisation-level sink so an attacker who compromises a project cannot erase the evidence:

# Configure audit logs
gcloud logging sinks create my-sink \
  storage.googleapis.com/my-audit-logs \
  --log-filter="resource.type=audit_log"

Cloud Asset Inventory completes the picture by making "what do we actually have" a query instead of an archaeology project:

# Export asset inventory
gcloud asset export \
  --project=my-project \
  --content-type=resource \
  --asset-types="compute.googleapis.com/Instance" \
  --output-path=gs://my-bucket/asset-inventory

Decision Framework

RiskPrimary control
Over-privileged users or workloadsLeast-privilege IAM by group, custom roles sparingly, org policy guardrails
Credential theftNo downloaded keys; attached identities, workload identity federation, VPC Service Controls behind them
Public data exposureUniform bucket-level access, public access prevention, SCC findings triage
Data exfiltration with valid credentialsVPC Service Controls perimeter with access levels
Regulatory key-custody requirementsCloud KMS with CMEK, or Cloud HSM / external key manager where mandated
Unknown sensitive data sprawlDLP discovery scans across BigQuery and Cloud Storage
Web application attacksCloud Armor policies on the load balancer

Implementation Checklist

  • [ ] Basic roles eliminated from daily use; IAM granted to groups at the right hierarchy level
  • [ ] Service account keys inventoried; attached identities used instead wherever possible
  • [ ] Organisation policies enforcing baseline guardrails (uniform bucket access, no default network, serial port off)
  • [ ] Public access prevention on storage; SCC findings reviewed on a cadence with owners assigned
  • [ ] KMS keys scoped per data domain with rotation set, where CMEK is required
  • [ ] Secrets in Secret Manager, never in code, images, or plain environment variables
  • [ ] VPC Service Controls designed, dry-run tested, and enforced around sensitive services
  • [ ] Audit logs exported to a separate, access-controlled destination
  • [ ] Cloud Armor policy on every public load balancer backend
  • Trade-offs

    Every control costs someone something. Least-privilege IAM generates access requests and debugging sessions; the alternative is a larger blast radius, and mature teams pay the friction deliberately. VPC Service Controls will break cross-perimeter workflows you forgot existed — dry-run mode exists because enforcement surprises are guaranteed. CMEK gives you revocation power and a new way to cause an outage, plus key-management overhead that Google-managed keys avoid entirely. Detection tooling without triage capacity produces alert fatigue and a false sense of coverage; a smaller set of controls that are actually operated beats a comprehensive set that is not.

    When Not to Use

  • Do not adopt CMEK everywhere by default: where no compliance or separation-of-duties requirement exists, Google-managed encryption is simpler and equally encrypted; CMEK is a control decision, not a security upgrade in itself.
  • Do not enforce VPC Service Controls on day one of a migration: dry-run first, or you will spend the migration debugging the perimeter instead of the workloads.
  • Do not write custom IAM roles prematurely: predefined roles cover most needs; a sprawling custom-role catalogue becomes its own audit problem.
  • Do not buy third-party security tooling before operating what GCP already includes — SCC, audit logs, and org policies close the common gaps first.
  • Conclusion

    GCP security is a stack of unglamorous disciplines: scoped identity, no portable credentials, guardrails at the organisation level, a perimeter around the data that matters, and findings that someone actually works through. None of the individual controls is exotic; the estates that get breached are missing the basics, not the advanced tier. Build the baseline in this guide and most real-world attack paths close.

    References

  • Cloud IAM Documentation
  • Cloud KMS Documentation
  • Security Command Center Documentation
  • Cloud Armor Documentation
  • Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

    Share this articleShare on XShare on LinkedIn

    Keep the decision frameworks coming

    One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.