Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)35k · #8043

implementing-gcp-organization-policy-constraints

Skill này làm gì

Công cụ này giúp đặt các quy tắc bảo mật cho tài khoản Google Cloud của bạn. Nó cho phép bạn kiểm soát những tài nguyên nào được tạo và cách chúng được cấu hình, đảm bảo mọi thứ tuân theo tiêu chuẩn bảo mật đã định.

Khi nào nên dùng

  • ✓Khi lần đầu thiết lập bảo mật cho tài khoản Google Cloud.
  • ✓Khi cần đảm bảo mọi tài nguyên mới đều tuân theo quy tắc bảo mật cụ thể.
  • ✓Khi tiến hành kiểm toán bảo mật để kiểm tra cấu hình có đúng không.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-gcp-organization-policy-constraints/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-gcp-organization-policy-constraints/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập quy tắc ngăn không cho dùng địa chỉ IP bên ngoài trên tất cả máy ảo trong tổ chức của tôi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn xác định quy tắc bảo mật muốn áp dụng (ví dụ: cấm IP bên ngoài), và công cụ thực hiện bằng các lệnh Google Cloud cụ thể hoặc công cụ như Terraform. Nó cũng cho phép bạn thử nghiệm các quy tắc ở chế độ “dry-run” trước khi bắt buộc áp dụng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Implementing 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
  • gcloud CLI configured and authenticated
  • Terraform or gcloud for policy management
  • Organization Policy Administrator IAM role (roles/orgpolicy.policyAdmin)

Core Concepts

Constraint Types

  1. List Constraints: Allow or deny specific values (e.g., allowed regions)
  2. Boolean Constraints: Enable or disable a capability (e.g., disable serial port access)
  3. 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

…
Câu hỏi thường gặp

“Constraints” là gì?

Đây là các quy tắc hoặc giới hạn bạn đặt ra để kiểm soát cách tài nguyên Google Cloud được sử dụng. Ví dụ, một quy tắc có thể hạn chế nơi tài nguyên được tạo.

Tôi có thể thử quy tắc trước khi áp dụng không?

Có, công cụ cho phép bạn kiểm tra tác động của quy tắc ở chế độ “dry-run” trước khi biến nó thành bắt buộc.

Mất bao lâu để quy tắc có hiệu lực?

Thay đổi chính sách có thể mất tới 15 phút để lan tỏa đến tất cả tài nguyên.

Chi tiết

Mô tả gốc của tác giả

Implements GCP Organization Policy constraints via gcloud and Terraform, such as restricting external IPs, resource locations, default service accounts, and service account keys, plus dry-run testing of policy impact before enforcement. Use when enforcing security guardrails across an org's resource hierarchy, or hardening GCP config at the org, folder, or project level.

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#8043
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự