
Implementing GCP Organization Policy Constraints
FreeEnforce security policies across GCP resources effectively.
Free · Opens the source repo
What Implementing GCP Organization Policy Constraints does
The Implementing GCP Organization Policy Constraints skill provides a structured approach to managing security and compliance within Google Cloud Platform (GCP). By leveraging the GCP Organization Policy Service, users can define and enforce constraints that govern the behavior of cloud resources at various levels, including organization, folder, and project. This capability is essential for organizations looking to enhance their security posture by restricting external IP access, managing resource locations, and controlling service account permissions.
The skill supports both gcloud and Terraform for policy management, allowing users to implement a range of constraints such as denying external IP addresses for virtual machines, enforcing OS login for SSH access, and restricting public IPs on Cloud SQL instances. Additionally, it offers a dry-run feature to simulate policy changes and assess their impact before actual enforcement, minimizing the risk of unintended disruptions.
This skill is particularly beneficial for security architects, compliance officers, and cloud administrators who are tasked with maintaining governance and security standards across their GCP environments. By utilizing the provided scripts and templates, users can quickly set up and manage organization policies that align with their security requirements and compliance mandates.
Overall, this skill streamlines the process of implementing GCP organization policies, ensuring that security measures are consistently applied and monitored across all cloud resources, thus aiding in the prevention of unauthorized access and data breaches.
When to use it
Use this skill when establishing or enforcing security policies in GCP to meet compliance requirements or improve security architecture.
When not to use it
This skill may not be suitable for environments that do not require strict governance or for users unfamiliar with GCP's organizational structure and policy management.
What you can build with it
Restricting External IPs on VMs
Use this skill to enforce policies that deny external IP addresses on all virtual machines, enhancing security against unauthorized access.
Managing Resource Locations
Implement policies that restrict resource locations to specific geographic areas, ensuring compliance with data residency requirements.
Enforcing Service Account Controls
Utilize the skill to disable automatic service account key creation, enforcing the use of Workload Identity for better security management.
How to install Implementing GCP Organization Policy Constraints
View source1. Install with the skills CLI
npx skills add mukul975/anthropic-cybersecurity-skills/implementing-gcp-organization-policy-constraints --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mukul975Implementing GCP Organization Policy Constraints
Overview
The GCP Organization Policy Service provides centralized and programmatic control over cloud resources. Organization policies configure constraints that restrict one or more Google Cloud services, enforced at organization, folder, or project levels. They improve security by blocking external IPs, requiring encryption, and minimizing unauthorized access. Changes can take up to 15 minutes to propagate.
When to Use
- When deploying or configuring implementing gcp organization policy constraints capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
- GCP Organization with Organization Administrator role
gcloudCLI configured and authenticated- Terraform or gcloud for policy management
- Organization Policy Administrator IAM role (
roles/orgpolicy.policyAdmin)
Core Concepts
Constraint Types
- List Constraints: Allow or deny specific values (e.g., allowed regions)
- Boolean Constraints: Enable or disable a capability (e.g., disable serial port access)
- Custom Constraints: User-defined rules targeting specific resource fields (Preview)
Policy Inheritance
Policies inherit from the lowest ancestor with an enforced policy. If no ancestor has a policy, Google's managed default behavior applies.
Essential Security Constraints
Restrict VM External IP Addresses
# Deny external IP addresses on all VMs
gcloud resource-manager org-policies set-policy \
--organization=ORGANIZATION_ID \
policy.yaml
policy.yaml:
constraint: constraints/compute.vmExternalIpAccess
listPolicy:
allValues: DENY
Restrict Resource Locations
gcloud org-policies set-policy \
--organization=ORGANIZATION_ID \
location-policy.yaml
location-policy.yaml:
constraint: constraints/gcp.resourceLocations
listPolicy:
allowedValues:
- "in:us-locations"
- "in:eu-locations"
Disable Default Service Account Creation
constraint: constraints/iam.automaticIamGrantsForDefaultServiceAccounts
booleanPolicy:
enforced: true
Require OS Login for SSH
constraint: constraints/compute.requireOsLogin
booleanPolicy:
enforced: true
Disable Serial Port Access
constraint: constraints/compute.disableSerialPortAccess
booleanPolicy:
enforced: true
Enforce Uniform Bucket-Level Access
constraint: constraints/storage.uniformBucketLevelAccess
booleanPolicy:
enforced: true
Restrict Public IP on Cloud SQL
constraint: constraints/sql.restrictPublicIp
booleanPolicy:
enforced: true
Disable Service Account Key Creation
constraint: constraints/iam.disableServiceAccountKeyCreation
booleanPolicy:
enforced: true
Terraform Implementation
resource "google_organization_policy" "restrict_vm_external_ip" {
org_id = var.org_id
constraint = "constraints/compute.vmExternalIpAccess"
list_policy {
deny {
all = true
}
}
}
resource "google_organization_policy" "restrict_locations" {
org_id = var.org_id
constraint = "constraints/gcp.resourceLocations"
list_policy {
allow {
values = ["in:us-locations", "in:eu-locations"]
}
}
}
resource "google_organization_policy" "require_os_login" {
org_id = var.org_id
constraint = "constraints/compute.requireOsLogin"
boolean_policy {
enforced = true
}
}
resource "google_folder_organization_policy" "dev_folder_external_ip" {
folder = google_folder.dev.name
constraint = "constraints/compute.vmExternalIpAccess"
list_policy {
allow {
values = ["projects/dev-project/zones/us-central1-a/instances/bastion-host"]
}
}
}
Dry-Run Testing
Use Policy Intelligence tools to test changes before enforcement:
# Create a dry-run policy to monitor impact
gcloud org-policies set-policy \
--organization=ORGANIZATION_ID \
dry-run-policy.yaml
dry-run-policy.yaml:
constraint: constraints/compute.vmExternalIpAccess
listPolicy:
allValues: DENY
dryRunSpec: true
# Check violations against dry-run policy
gcloud org-policies list-custom-constraints \
--organization=ORGANIZATION_ID
Custom Constraints
# custom-constraint.yaml
name: organizations/ORGANIZATION_ID/customConstraints/custom.disableGKEAutoUpgrade
resourceTypes:
- container.googleapis.com/NodePool
methodTypes:
- CREATE
- UPDATE
condition: "resource.management.autoUpgrade == true"
actionType: DENY
displayName: Deny GKE auto-upgrade on node pools
description: Prevents enabling auto-upgrade on GKE node pools for controlled upgrades
gcloud org-policies set-custom-constraint custom-constraint.yaml
Monitoring and Compliance
List active policies
gcloud org-policies list --organization=ORGANIZATION_ID
Describe a specific policy
gcloud org-policies describe constraints/compute.vmExternalIpAccess \
--organization=ORGANIZATION_ID
Audit policy violations with Cloud Asset Inventory
gcloud asset search-all-resources \
--scope=organizations/ORGANIZATION_ID \
--query="policy:constraints/compute.vmExternalIpAccess"
Recommended Baseline Policies
| Constraint | Type | Scope | Purpose |
|---|---|---|---|
| compute.vmExternalIpAccess | List/Deny | Org | Prevent public VM IPs |
| gcp.resourceLocations | List/Allow | Org | Restrict to approved regions |
| iam.disableServiceAccountKeyCreation | Boolean | Org | Force Workload Identity |
| compute.requireOsLogin | Boolean | Org | Mandate OS Login for SSH |
| storage.uniformBucketLevelAccess | Boolean | Org | Enforce uniform bucket access |
| sql.restrictPublicIp | Boolean | Org | No public Cloud SQL |
| compute.disableSerialPortAccess | Boolean | Org | Disable serial port |
| compute.disableNestedVirtualization | Boolean | Org | No nested VMs |
References
- GCP Organization Policy Constraints: https://docs.google.com/resource-manager/docs/organization-policy/org-policy-constraints
- GCP Policy Intelligence: https://cloud.google.com/policy-intelligence
- CIS GCP Foundations Benchmark
Frequently asked questions about Implementing GCP Organization Policy Constraints
Similar skills
Data Breach Blast Radius Analyzer
Assess potential breach impacts before they occur.
Verify Agent Action
Ensure safe execution of AI agent actions with thorough reviews.
Agent Supply Chain Integrity
Ensure the integrity of AI agent plugins and tools.
Agent OWASP ASI Compliance Check
Ensure your AI agents meet OWASP ASI security standards.
Securing S3 Buckets
Enhance your S3 bucket security with AWS best practices.
AWS Account Enumeration with ScoutSuite
Assess AWS security posture with comprehensive audits.
