{"id":"59775f2d-9efd-46eb-b7b1-ae30821bce4f","slug":"google-cloud-recipe-foundation-builder","kind":"skill","name":"google-cloud-recipe-foundation-builder","summary":"Deploys a baseline landing zone foundation for a Google Cloud Organization, establishing security guardrails using Organization Policies, resource hierarchy folders and projects, billing association,","owner":"google","repoUrl":"https://github.com/google/skills/tree/HEAD/skills/cloud/google-cloud-recipe-foundation-builder","license":"Apache-2.0","licenseTier":"permissive","trust":"official","stars":21260,"match":null,"fewStars":false,"format":"skill","createdAt":null,"addedAt":"2026-10-14T05:35:44.766Z","logoUrl":"https://avatars.githubusercontent.com/u/1342004?v=4","linkOnly":false,"collection":{"name":"skills","repo":"google/skills"},"skillPath":"skills/cloud/google-cloud-recipe-foundation-builder","categories":["cloud-infra"],"tags":["google","googlecloud"],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-14T05:35:44.764Z","sample":false,"url":"https://conduits.dev/tools/google-cloud-recipe-foundation-builder","language":"Python","transports":[],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"> Deploys a baseline landing zone foundation for a Google Cloud Organization, establishing security guardrails using Organization Policies, resource hierarchy folders and projects, billing association, and centralized logging and monitoring. Deploys Google Cloud's recommended security controls and architecture. Use when setting up a new Google Cloud Organization or establishing a secure, enterprise-grade landing zone foundation. Don't use for individual project onboarding (use google-cloud-recipe-onboarding or product-specific skills instead).\n\n# Google Cloud Recipe: Foundation Builder\n\n> [!WARNING] This skill is currently in a preview state. It will deploy a secure\n> foundation, but does not have all advanced features. Users who want more\n> options should visit\n> [Google Cloud Setup](https://docs.cloud.google.com/docs/enterprise/cloud-setup).\n\nThis skill guides the setup of a secure, enterprise-grade Google Cloud landing\nzone foundation. It establishes baseline security controls, organizes the\ninitial resource hierarchy, and configures centralized audit logging and\ncross-environment monitoring.\n\n## Overview\n\nThe recipe provisions the following core components at the organization root:\n\n*   **Security Guardrails**: Enforces 17 baseline Google Cloud Organization\n    Policies to secure the environment (13 Boolean, 4 List constraints).\n*   **Resource Hierarchy**: Establishes 4 folders (`Common`, `Production`,\n    `Non-Production`, `Development`) and provisions corresponding projects\n    sequentially with globally unique ID prefixes (`logging-`, `prod-`,\n    `non-prod-`, `dev-` followed by a shared suffix).\n*   **Billing & API Enablement**: Links all projects to your billing account and\n    activates critical logging/monitoring services.\n*   **Centralized Logging & Monitoring**: Deploys a global, centralized log\n    bucket with 30-day retention, configures an organization-wide audit log\n    sink, and sets up a cross-environment metrics scope.\n\n--------------------------------------------------------------------------------\n\n## Clarifying Questions\n\nBefore executing this recipe, the agent **must** gather the following details:\n\n1.  **Organization ID**: Run `gcloud organizations list` to retrieve the\n    available organizations, present them to the user, and ask them to select\n    the target **Organization ID**.\n2.  **Billing Account ID**: Run `gcloud billing accounts list\n    --filter=open=true` to retrieve only the active (open) billing accounts,\n    present them to the user, and ask them to select the active **Billing\n    Account ID**.\n3.  **Project ID Suffix**: Ask if the user has a preferred prefix or target\n    suffix for Project IDs (default uses prefix + a shared random 8-character\n    string, e.g., `prod-ab12cd34`).\n4.  **Log Bucket Region**: Ask for the target region for resources if they want\n    to override the default `global` log bucket location.\n\n--------------------------------------------------------------------------------\n\n## Prerequisites\n\nEnsure the following prerequisites are met before beginning the deployment:\n\n*   **GCP Identity**: You must have a Google Cloud Organization resource set up.\n*   **Administrative IAM Roles**: The identity executing these commands must\n    hold the required administrative permissions. If any step fails with a\n    `Permission Denied` error, the agent will attempt to self-remediate by\n    granting the corresponding recommended role as detailed in **Phase 2: Error\n    Recovery & Lazy Role Remediation Strategy**.\n*   **Tools**: The `gcloud` CLI must be installed, authorized with the above\n    identity, and configured for use.\n\n--------------------------------------------------------------------------------\n\n## Steps to Complete the Recipe\n\n### Phase 1: Pre-flight Confirmation\n\nIdentify the target organization and obtain explicit user approval before making\nchanges.\n\n1.  **Identify and Discover Organization**: Verify the target organization. If\n    only the display name is known, list organizations to find the ID. Then,\n    retrieve the organization metadata to dynamically calculate the **Directory\n    Customer ID** and **Domain Name**:\n\n    ```bash\n    # List to find ID if needed\n    gcloud organizations list\n\n    # Describe the organization to retrieve metadata\n    gcloud organizations describe [ORGANIZATION_ID]\n    ```\n\n    *Calculate values:*\n\n    *   **Domain Name** (`[ORG_NAME]` / `[YOUR_DOMAIN]`): Use the `displayName`\n        value from the output (e.g., `my-business.com`).\n    *   **Customer ID** (`[DIRECTORY_CUSTOMER_ID]`): Use the\n        `owner.directoryCustomerId` value from the output (e.g., `C01234567`).\n\n2.  **Present Blueprint Summary**: Present the exact details of the blueprint to\n    the user and request confirmation to proceed:\n\n    > **Proposed Foundation Deployment Summary for Organization: `[ORG_NAME]`\n    > (`[ORGANIZATION_ID]`)**\n    >\n    > *   **Security:** Enforce 17 baseline Organization Policies (13 Boolean, 4\n    >     List).\n    > *   **Folders:** Create 4 folders sequentially (`Common`, `Production`,\n    >     `Non-Production`, `Development`).\n    > *   **Projects:** Create 4 projects sequentially with unique IDs\n    >     (`logging-[SUFFIX]`, `prod-[SUFFIX]`, `non-prod-[SUFFIX]`,\n    >     `dev-[SUFFIX]`).\n    > *   **Billing:** Link all projects to Billing Account\n    >     `[BILLING_ACCOUNT_ID]`.\n    > *   **APIs:** Enable Logging and Monitoring APIs on the central project.\n    > *   **Centralized Logging:** Deploy a `global` log bucket\n    >     `[ORG_NAME]-logging` (30-day retention), configure an\n    >     organization-level sink\n    >     `[ORGANIZATION_ID]-logbucketsink-[RANDOM_HEX]`, and establish\n    >     cross-project metrics scopes.\n    >\n    > Do you wish to proceed with this deployment? (Yes/No)\n\n> [!IMPORTANT] **Pause execution** and wait for explicit user approval before\n> moving to Phase 2. If the user declines, abort the operation.\n\n### Phase 2: Error Recovery & Lazy Role Remediation Strategy\n\nTo ensure deployment continues smoothly on clean organizations without requiring\ncomplex upfront permission checks (which require a quota project), the agent\n**must** adopt a \"lazy recovery\" approach.\n\nInstead of testing permissions in advance, the agent will attempt to execute\neach step in the recipe. If a step fails with a `Permission Denied` error, the\nagent will attempt to self-remediate by granting the corresponding recommended\nadministrative group of roles to the deployment identity and retrying the\noperation.\n\n> [!IMPORTANT] When asked about pre-deployment readiness, prerequisites, or\n> checks to run, the agent **must** explicitly explain that the landing zone\n> deployment adopts a lazy role remediation strategy rather than upfront\n> testing, detailing all of the following in its response: 1. Confirm it will\n> execute deployment commands directly, catching any Permission Denied\n> errors. 2. Confirm it will attempt to self-remediate on failure by running the\n> exact commands `gcloud organizations add-iam-policy-binding` or `gcloud\n> billing accounts add-iam-policy-binding` to grant the entire administrative\n> group of roles to the active identity, and then retry the failed deployment\n> command. 3. List the core administrative groups that it will attempt to grant\n> (Organization Admin Group, Billing Admin Group, and Security Admin Group)\n> mapped to their key roles. 4. Confirm it will halt execution and request\n> manual administrator intervention if the self-remediation grant command fails.\n\n#### Remediation Protocol\n\nFor any command that fails due to missing permissions:\n\n1.  **Identify Required Admin Group**: Determine which administrative group is\n    responsible for the failed action. Refer to the\n    [Administrative IAM Reference](references/admin-iam.md#core-administrative-groups--roles)\n    for details.\n2.  **Attempt Self-Remediation**: Grant **all** roles belonging to that\n    administrative group to the active authenticated account sequentially. Refer\n    to the\n    [Administrative IAM Reference Remediation Guide](references/admin-iam.md#remediation)\n    for the copy-pasteable script commands:\n\n    *   **For Organization/Folder level failures (Org Admin Group or Security\n        Admin Group)**: Run `gcloud organizations add-iam-policy-binding`\n        sequentially for each role in the group.\n    *   **For Billing level failures (Billing Admin Group)**: Run `gcloud\n        billing accounts add-iam-policy-binding` sequentially for each role in\n        the group.\n\n3.  **Halt on Remediation Failure**:\n\n    *   If the grant commands succeed, immediately retry the failed deployment\n        command.\n    *   If any of the grant commands fail (e.g., due to lack of `setIamPolicy`\n        admin rights), **halt execution** and instruct the user to ask their\n        Organization/Billing Administrator to manually grant the entire\n        administrative group of roles.\n\n#### Phase-Specific Remediation Mapping\n\n*   **Phase 3: Security Guardrails (Org Policies)**:\n    *   If `gcloud org-policies set-policy` fails: Attempt to grant the entire\n        **Organization Admin Group** (9 roles) at the organization level.\n*   **Phase 4: Resource Hierarchy (Folders & Projects)**:\n    *   If `gcloud resource-manager folders create` or `gcloud projects create`\n        fails: Attempt to grant the entire **Organization Admin Group** (9\n        roles) at the organization level.\n*   **Phase 4: Billing Link**:\n    *   If `gcloud billing projects link` fails: Attempt to grant the entire\n        **Billing Admin Group** (3 roles) at the billing account level, and\n        ensure the active identity is granted the **Organization Admin Group**\n        (which contains `roles/billing.user`) at the organization level.\n*   **Phase 5: Centralized Logging & Monitoring**:\n    *   If `gcloud logging sinks create` fails at org level: Attempt to grant\n        the entire **Logging/Monitoring Admin Group** (2 roles:\n        `roles/logging.admin`, `roles/monitoring.admin`) and the **Security\n        Admin Group** (9 roles) at the organization level.\n\n### Phase 3: Security Guardrails (Org Policies)\n\nApply 17 baseline security controls at the organization root.\n\n> [!CAUTION] Applying `iam.allowedPolicyMemberDomains` first can lock out the\n> deployment identity if it resides in an unallowed domain. Ensure the\n> deployment identity is safe before enforcing this policy.\n\n1.  Generate the YAML configuration files for the 17 policies. Refer to the\n    [Organization Policies Reference](references/org-policies.md) for the exact\n    YAML templates for both Boolean and List constraints.\n2.  Apply each organization policy sequentially using the `gcloud org-policies`\n    tool:\n\n    ```bash\n    gcloud org-policies set-policy [POLICY_FILE_NAME].yaml\n    ```\n\n### Phase 4: Resource Hierarchy\n\n#### 1. Folder Creation\n\nCheck if target folders exist to avoid duplication. The agent must check for all\n4 folders: for any folder that already exists (e.g., if `Common` or `Production`\nare already present), the agent must locate and reuse them; for any folder that\nis missing (e.g., if `Non-Production` or `Development` are not present), the\nagent must proceed to sequentially create them:\n\n> [!IMPORTANT] When explaining how existing resources (folders and projects) are\n> handled to prevent duplication, the agent **must** explicitly name the\n> remaining missing folders (`Non-Production` and `Development`) and confirm\n> that it will proceed to sequentially create only these missing folders and\n> projects.\n\n```bash\n# Check and Create \"Common\" Folder\ngcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter=\"display_name=Common\"\n# If not present:\ngcloud resource-manager folders create --display-name=\"Common\" --organization=[ORGANIZATION_ID]\n\n# Check and Create \"Production\" Folder\ngcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter=\"display_name=Production\"\n# If not present:\ngcloud resource-manager folders create --display-name=\"Production\" --organization=[ORGANIZATION_ID]\n\n# Check and Create \"Non-Production\" Folder\ngcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter=\"display_name=Non-Production\"\n# If not present:\ngcloud resource-manager folders create --display-name=\"Non-Production\" --organization=[ORGANIZATION_ID]\n\n# Check and Create \"Development\" Folder\ngcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter=\"display_name=Development\"\n# If not present:\ngcloud resource-manager folders create --display-name=\"Development\" --organization=[ORGANIZATION_ID]\n```\n\n#### 2. Project Creation and Billing Link\n\nCheck if target projects already exist in the folders by matching their display\nnames. If not present, generate a shared 8-character random suffix (e.g.,\n`ab12cd34`) and create the projects sequentially, linking billing and enabling\nAPIs immediately:\n\n```bash\n# Check if \"central-logging-monitoring\" project exists in Common folder\ngcloud projects list --filter=\"parent.id=[COMMON_FOLDER_ID] AND parent.type=folder AND name=central-logging-monitoring\"\n\n# If not present: Create, link billing, and enable APIs\ngcloud projects create logging-[SUFFIX] --name=\"central-logging-monitoring\" --folder=[COMMON_FOLDER_ID]\ngcloud billing projects link logging-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]\ngcloud services enable compute.googleapis.com logging.googleapis.com monitoring.googleapis.com --project=logging-[SUFFIX]\n\n# Check if \"production\" project exists in Production folder\ngcloud projects list --filter=\"parent.id=[PRODUCTION_FOLDER_ID] AND parent.type=folder AND name=production\"\n\n# If not present: Create, link billing, and enable APIs\ngcloud projects create prod-[SUFFIX] --name=\"production\" --folder=[PRODUCTION_FOLDER_ID]\ngcloud billing projects link prod-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]\ngcloud services enable compute.googleapis.com run.googleapis.com container.googleapis.com artifactregistry.googleapis.com firestore.googleapis.com pubsub.googleapis.com aiplatform.googleapis.com cloudaicompanion.googleapis.com apphub.googleapis.com designcenter.googleapis.com discoveryengine.googleapis.com iam.googleapis.com config.googleapis.com cloudbuild.googleapis.com cloudasset.googleapis.com cloudkms.googleapis.com cloudresourcemanager.googleapis.com --project=prod-[SUFFIX]\n\n# Check if \"non-production\" project exists in Non-Production folder\ngcloud projects list --filter=\"parent.id=[NON_PRODUCTION_FOLDER_ID] AND parent.type=folder AND name=non-production\"\n\n# If not present: Create, link billing, and enable APIs\ngcloud projects create non-prod-[SUFFIX] --name=\"non-production\" --folder=[NON_PRODUCTION_FOLDER_ID]\ngcloud billing projects link non-prod-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]\ngcloud services enable compute.googleapis.com run.googleapis.com container.googleapis.com artifactregistry.googleapis.com firestore.googleapis.com pubsub.googleapis.com aiplatform.googleapis.com cloudaicompanion.googleapis.com apphub.googleapis.com designcenter.googleapis.com discoveryengine.googleapis.com iam.googleapis.com config.googleapis.com cloudbuild.googleapis.com cloudasset.googleapis.com cloudkms.googleapis.com cloudresourcemanager.googleapis.com --project=non-prod-[SUFFIX]\n\n# Check if \"development\" project exists in Development folder\ngcloud projects list --filter=\"parent.id=[DEVELOPMENT_FOLDER_ID] AND parent.type=folder AND name=development\"\n\n# If not present: Create, link billing, and enable APIs\ngcloud projects create dev-[SUFFIX] --name=\"development\" --folder=[DEVELOPMENT_FOLDER_ID]\ngcloud billing projects link dev-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]\ngcloud services enable compute.googleapis.com run.googleapis.com container.googleapis.com artifactregistry.googleapis.com firestore.googleapis.com pubsub.googleapis.com aiplatform.googleapis.com cloudaicompanion.googleapis.com apphub.googleapis.com designcenter.googleapis.com discoveryengine.googleapis.com iam.googleapis.com config.googleapis.com cloudbuild.googleapis.com cloudasset.googleapis.com cloudkms.googleapis.com cloudresourcemanager.googleapis.com --project=dev-[SUFFIX]\n```\n\n> [!NOTE] **Agentic Parallelism Option**: While the manual runbook enforces\n> sequential project execution to avoid terminal race conditions, an AI agent\n> with multi-agent orchestration capability may optionally spawn subagents to\n> provision the 4 projects in parallel once folder IDs are resolved.\n\n### Phase 5: Centralized Logging and Monitoring\n\nConfigure centralized audit logging and cross-project monitoring scope in the\n`logging-[SUFFIX]` project.\n\nRefer to the\n[Centralized Logging and Monitoring Reference](references/logging-monitoring.md)\nfor the detailed step-by-step commands to:\n\n1.  Create the central log bucket.\n2.  Create the organization-wide log sink.\n3.  Grant required IAM permissions to the log sink.\n4.  Configure the cross-project monitoring metrics scope.\n\n--------------------------------------------------------------------------------\n\n## Validation Logic & Checklist\n\nEvaluate the deployment against the following verification checks:\n\n-   [ ] **Security Policies**: Run `gcloud org-policies list\n    --organization=[ORGANIZATION_ID]` and verify all 17 target policies are\n    enforced or correctly configured.\n-   [ ] **Resource Folders**: Verify folders `Common`, `Production`,\n    `Non-Production`, and `Development` exist under the organization root.\n-   [ ] **Billing Linkage**: Run `gcloud billing projects list` and assert that\n    all 4 newly created projects are linked to your billing account.\n-   [ ] **Log Bucket & Retention**: Verify the log bucket `[ORG_NAME]-logging`\n    exists in project `logging-[SUFFIX]`, is located in `global`, and has a\n    retention period of exactly 30 days.\n-   [ ] **Log Sink Routing**: Run `gcloud logging sinks describe` at the\n    organization level and confirm the sink routes cloud audit logs to the\n    global bucket and holds standard `writerIdentity` credentials.\n-   [ ] **Metrics Scope Linkage**: Run `gcloud beta monitoring metrics-scopes\n    describe` and assert that the `dev`, `non-prod`, and `prod` projects appear\n    in the monitored list of the central `logging` project.\n\n--------------------------------------------------------------------------------\n\n## Links\n\n*   [Google Cloud Resource Hierarchy Documentation](https://cloud.google.com/resource-manager/docs/creating-managing-organization)\n*   [Google Cloud Organization Policies Overview](https://cloud.google.com/resource-manager/docs/organization-policy/overview)\n*   [Centralized Audit Logging Best Practices](https://cloud.google.com/architecture/security-foundations/logging-monitoring)\n*   [Cloud Monitoring Metrics Scopes Configuration](https://cloud.google.com/monitoring/settings/multiple-projects)\n*   [Gcloud Logging Sinks CLI Reference](https://cloud.google.com/sdk/gcloud/reference/logging/sinks)\n*   [Google Cloud Landing Zones Guide](https://docs.cloud.google.com/architecture/landing-zones)\n*   [Google Cloud Security Foundations Blueprint](https://docs.cloud.google.com/architecture/blueprints/security-foundations)"}