From gcp
Provision and sync GCP IAM resources — IAM bindings at Organization / Folder / Project scope, custom roles, service accounts with Workload Identity Federation, and organization policies — from a core-iam.yaml and tenant.yaml definition. Uses the GCP MCP server. Use when applying or updating IAM changes on GCP after running define-core-iam or define-tenant-iam.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gcp:manage-gcp-iamThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implementation
Implementation
resourcemanager.projects.setIamPolicy, resourcemanager.folders.setIamPolicyiam.serviceAccounts.create, iam.serviceAccounts.setIamPolicyiam.roles.create, iam.roles.update (if custom roles are needed)iam.workloadIdentityPools.create, iam.workloadIdentityPools.updateRole("admin") SDK (if managing groups)design-segmentation).Apply the IAM definitions from core-iam.yaml and/or one or more tenants/{name}.yaml files to GCP. Ensure that:
Role("operator") identities exist with Workload Identity Federation pools and providers configured.Role("operator") identities.This skill is idempotent: running it multiple times produces the same result.
When writing configurations or documentation, you MUST strictly adhere to the structural notation and types defined in the book. Before proceeding, read the following reference files:
references/notation.mdreferences/types.mdBefore proceeding, ask the user (or infer from context):
core-iam.yaml and/or tenants/{name}.yaml. Read these files first.Role("admin") SDK calls.(Sector, Tier) or one global pool — discuss trade-offs with the user).Read the IAM definition files before proceeding.
Read the specified IAM definition files. Extract:
Role("operator") groupsValidate the definitions:
Role("operator") groupsReport validation errors and stop before applying any changes.
For each group declared in the IAM definition:
[email protected]).Role("operator") groups: verify zero human members. Report and remove any found.If groups are synced via SCIM from an external IdP, skip creation — only verify existence and log a note that membership is managed externally.
Map each group to the correct GCP predefined role and resource scope:
| Group Pattern | GCP Role | Scope |
|---|---|---|
{sector}-{tier}-operator | roles/editor + permission boundary via Org Policy | Project (sector, tier) |
{sector}-{tier}-admins | roles/owner | Project (sector, tier) — via IAM Condition for time-bound access |
{sector}-{tier}-contributors | roles/editor | Project (sector, tier) |
{sector}-{tier}-readers | roles/viewer | Folder ({sector}) |
{tenant}-{tier}-operator | Service Account binding | Project ({sector}, {tier}, _, {tenant}) |
{tenant}-{tier}-admins | roles/owner (scoped) | Project for tenant |
{tenant}-{tier}-contributors | roles/editor | Project for tenant |
{tenant}-readers | roles/viewer | Project(s) for tenant's declared sectors |
For each binding:
setIamPolicy call per resource (do not issue one API call per member — batch the policy update to avoid race conditions).IAM Conditions for Role("admin") roles: Where available, use IAM conditions to restrict Role("admin") bindings to a time window or require specific resource-level access justification (Access Approval). Document this in the output.
Custom roles: If the predefined roles (editor, viewer) are too broad for the tenant's use case, define a custom role with only the permissions the tenant's workloads require. Create it at the Project or Organization level as appropriate. Prefer Organization-level custom roles for reuse across projects.
For each Role("operator") group's Workload Identity definition:
{sector}-{tier}.audience field in the definition.google.subject ← assertion.subattribute.repository ← assertion.repository (for GitHub Actions)attribute.ref ← assertion.ref (for branch-based conditions)Role("operator") (e.g., payments-live-operator@{project}.iam.gserviceaccount.com).roles/iam.workloadIdentityUser to the pool/provider/subject combination on the service account — this is the binding that allows the external identity to impersonate the account.Complement IAM bindings with Organization Policy constraints to enforce boundaries that IAM alone cannot:
iam.disableServiceAccountKeyCreation: Prevent creation of service account keys in all projects.iam.disableServiceAccountKeyUpload: Prevent uploading external keys.iam.allowedPolicyMemberDomains: Restrict IAM members to the organization's domain — prevents accidentally granting access to external Gmail accounts.Check whether these policies are already set at the Organization or Folder level. If not, recommend enabling them and confirm with the user before applying (Organization Policies are wide in scope).
GCP does not have a built-in JIT tool equivalent to Azure PIM. Available options:
request.time condition to make them automatically expire. Use this for time-bound Role("admin") access.Role("admin") roles on sensitive projects, enable Access Approval to require manual approval before the access is granted at the API level.For each Role("admin") and Tier("live") Role("contributor") group, document the JIT strategy in the output. Flag groups with permanent roles/owner bindings on Tier("live") projects and recommend a remediation.
Produce a summary after applying:
In dry-run mode, produce the report without making changes.
Produce a Markdown report named gcp-iam-report.md:
``markdown
Date: [timestamp] Scope: [core / tenant names applied] Mode: [applied / dry-run]
| Group | Status | Members Added | Members Removed |
|---|---|---|---|
| [email protected] | created | 1 | 0 |
| Group | Role | Resource | Condition | Status |
|---|---|---|---|---|
| platform-sandbox-readers | roles/viewer | folders/123456 | — | created |
| payments-live-admins | roles/owner | projects/payments-live | expiry: 2h | created |
| Pool | Provider | Service Account | Attribute Condition | Status |
|---|---|---|---|---|
| ecommerce-live | github-actions | payments-live-operator@ | sub=repo:mountainlab/payments-service:environment:live | created |
| Policy | Status | Recommendation |
|---|---|---|
| iam.disableServiceAccountKeyCreation | not set | Enable at Org level |
| Group | Strategy | Standing Tier("live") Write | Remediation Needed |
|---|---|---|---|
| payments-live-admins | IAM condition expiry | no | no |
[Service account keys found, unrestricted pool impersonation, permanent owner bindings, etc.]
[Actions requiring manual intervention or external tooling configuration] ``
Role("reader") at the Folder level cascades to all projects below it. This is the correct pattern for cross-project read access (e.g., a monitoring tool reading all projects in a sector).roles/owner on Tier("live") projects is an anti-pattern. Use expiring conditions or PAM to enforce time-bound access.This skill is grounded in Chapter 5: Identity and Access Management of Crafting Platforms.
npx claudepluginhub craftingplatforms/ai --plugin gcpAudits GCP IAM bindings across org/folder/project, identifies overprivileged SAs, reviews Workload Identity Federation, and recommends least-privilege remediation.
Builds least-privilege IAM setups: roles, policies, service accounts for cloud services. Generates IaC using Terraform, Pulumi, CloudFormation.
Build IAM from scratch — roles, policies, service accounts with least privilege. Use when asked to "set up IAM", "create roles", "service accounts", or "access control".