Google Cloud Foundation Builder

Google Cloud Foundation Builder

Deploys a secure baseline landing zone for a Google Cloud organization with org policies, folders, projects, billing, and centralized logging and monitoring.

Skill files5 files

references/

SKILL.md366 lines
1
---
2
name: google-cloud-recipe-foundation-builder
3
metadata:
4
version: "1.0.1"
5
category: GettingStarted
6
description: >-
7
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.
8
Use when setting up a new Google Cloud Organization or establishing a secure, enterprise-grade landing zone foundation.
9
10
Don't use for individual project onboarding (use google-cloud-recipe-onboarding or product-specific skills instead).
11
---
12
13
# Google Cloud Recipe: Foundation Builder
14
15
> [!WARNING] This skill is currently in a preview state. It will deploy a secure
16
> foundation, but does not have all advanced features. Users who want more
17
> options should visit
18
> [Google Cloud Setup](https://docs.cloud.google.com/docs/enterprise/cloud-setup).
19
20
This skill guides the setup of a secure, enterprise-grade Google Cloud landing
21
zone foundation. It establishes baseline security controls, organizes the
22
initial resource hierarchy, and configures centralized audit logging and
23
cross-environment monitoring.
24
25
## Attribution
26
27
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
28
MUST read [Usage Attribution](references/attribution.md). For commands executed
29
directly in the terminal (never in generated scripts, Terraform, or user code),
30
prefix `gcloud` with
31
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:google-cloud-recipe-foundation-builder)"`
32
and append `agent-skills/1.0 (skill:google-cloud-recipe-foundation-builder)` to `User-Agent` headers.
33
34
## Overview
35
36
The recipe provisions the following core components at the organization root:
37
38
* **Security Guardrails**: Enforces 17 baseline Google Cloud Organization
39
Policies to secure the environment (13 Boolean, 4 List constraints).
40
* **Resource Hierarchy**: Establishes 4 folders (`Common`, `Production`,
41
`Non-Production`, `Development`) and provisions corresponding projects
42
sequentially with globally unique ID prefixes (`logging-`, `prod-`,
43
`non-prod-`, `dev-` followed by a shared suffix).
44
* **Billing & API Enablement**: Links all projects to your billing account and
45
activates critical logging/monitoring services.
46
* **Centralized Logging & Monitoring**: Deploys a global, centralized log
47
bucket with 30-day retention, configures an organization-wide audit log
48
sink, and sets up a cross-environment metrics scope.
49
50
--------------------------------------------------------------------------------
51
52
## Clarifying Questions
53
54
Before executing this recipe, the agent **must** gather the following details:
55
56
1. **Organization ID**: Run `gcloud organizations list` to retrieve the
57
available organizations, present them to the user, and ask them to select
58
the target **Organization ID**.
59
2. **Billing Account ID**: Run `gcloud billing accounts list
60
--filter=open=true` to retrieve only the active (open) billing accounts,
61
present them to the user, and ask them to select the active **Billing
62
Account ID**.
63
3. **Project ID Suffix**: Ask if the user has a preferred prefix or target
64
suffix for Project IDs (default uses prefix + a shared random 8-character
65
string, e.g., `prod-ab12cd34`).
66
4. **Log Bucket Region**: Ask for the target region for resources if they want
67
to override the default `global` log bucket location.
68
69
--------------------------------------------------------------------------------
70
71
## Prerequisites
72
73
Ensure the following prerequisites are met before beginning the deployment:
74
75
* **GCP Identity**: You must have a Google Cloud Organization resource set up.
76
* **Administrative IAM Roles**: The identity executing these commands must
77
hold the required administrative permissions. If any step fails with a
78
`Permission Denied` error, the agent will attempt to self-remediate by
79
granting the corresponding recommended role as detailed in **Phase 2: Error
80
Recovery & Lazy Role Remediation Strategy**.
81
* **Tools**: The `gcloud` CLI must be installed, authorized with the above
82
identity, and configured for use.
83
84
--------------------------------------------------------------------------------
85
86
## Steps to Complete the Recipe
87
88
### Phase 1: Pre-flight Confirmation
89
90
Identify the target organization and obtain explicit user approval before making
91
changes.
92
93
1. **Identify and Discover Organization**: Verify the target organization. If
94
only the display name is known, list organizations to find the ID. Then,
95
retrieve the organization metadata to dynamically calculate the **Directory
96
Customer ID** and **Domain Name**:
97
98
```bash
99
# List to find ID if needed
100
gcloud organizations list
101
102
# Describe the organization to retrieve metadata
103
gcloud organizations describe [ORGANIZATION_ID]
104
```
105
106
*Calculate values:*
107
108
* **Domain Name** (`[ORG_NAME]` / `[YOUR_DOMAIN]`): Use the `displayName`
109
value from the output (e.g., `my-business.com`).
110
* **Customer ID** (`[DIRECTORY_CUSTOMER_ID]`): Use the
111
`owner.directoryCustomerId` value from the output (e.g., `C01234567`).
112
113
2. **Present Blueprint Summary**: Present the exact details of the blueprint to
114
the user and request confirmation to proceed:
115
116
> **Proposed Foundation Deployment Summary for Organization: `[ORG_NAME]`
117
> (`[ORGANIZATION_ID]`)**
118
>
119
> * **Security:** Enforce 17 baseline Organization Policies (13 Boolean, 4
120
> List).
121
> * **Folders:** Create 4 folders sequentially (`Common`, `Production`,
122
> `Non-Production`, `Development`).
123
> * **Projects:** Create 4 projects sequentially with unique IDs
124
> (`logging-[SUFFIX]`, `prod-[SUFFIX]`, `non-prod-[SUFFIX]`,
125
> `dev-[SUFFIX]`).
126
> * **Billing:** Link all projects to Billing Account
127
> `[BILLING_ACCOUNT_ID]`.
128
> * **APIs:** Enable Logging and Monitoring APIs on the central project.
129
> * **Centralized Logging:** Deploy a `global` log bucket
130
> `[ORG_NAME]-logging` (30-day retention), configure an
131
> organization-level sink
132
> `[ORGANIZATION_ID]-logbucketsink-[RANDOM_HEX]`, and establish
133
> cross-project metrics scopes.
134
>
135
> Do you wish to proceed with this deployment? (Yes/No)
136
137
> [!IMPORTANT] **Pause execution** and wait for explicit user approval before
138
> moving to Phase 2. If the user declines, abort the operation.
139
140
### Phase 2: Error Recovery & Lazy Role Remediation Strategy
141
142
To ensure deployment continues smoothly on clean organizations without requiring
143
complex upfront permission checks (which require a quota project), the agent
144
**must** adopt a "lazy recovery" approach.
145
146
Instead of testing permissions in advance, the agent will attempt to execute
147
each step in the recipe. If a step fails with a `Permission Denied` error, the
148
agent will attempt to self-remediate by granting the corresponding recommended
149
administrative group of roles to the deployment identity and retrying the
150
operation.
151
152
> [!IMPORTANT] When asked about pre-deployment readiness, prerequisites, or
153
> checks to run, the agent **must** explicitly explain that the landing zone
154
> deployment adopts a lazy role remediation strategy rather than upfront
155
> testing, detailing all of the following in its response: 1. Confirm it will
156
> execute deployment commands directly, catching any Permission Denied
157
> errors. 2. Confirm it will attempt to self-remediate on failure by running the
158
> exact commands `gcloud organizations add-iam-policy-binding` or `gcloud
159
> billing accounts add-iam-policy-binding` to grant the entire administrative
160
> group of roles to the active identity, and then retry the failed deployment
161
> command. 3. List the core administrative groups that it will attempt to grant
162
> (Organization Admin Group, Billing Admin Group, and Security Admin Group)
163
> mapped to their key roles. 4. Confirm it will halt execution and request
164
> manual administrator intervention if the self-remediation grant command fails.
165
166
#### Remediation Protocol
167
168
For any command that fails due to missing permissions:
169
170
1. **Identify Required Admin Group**: Determine which administrative group is
171
responsible for the failed action. Refer to the
172
[Administrative IAM Reference](references/admin-iam.md#core-administrative-groups--roles)
173
for details.
174
2. **Attempt Self-Remediation**: Grant **all** roles belonging to that
175
administrative group to the active authenticated account sequentially. Refer
176
to the
177
[Administrative IAM Reference Remediation Guide](references/admin-iam.md#remediation)
178
for the copy-pasteable script commands:
179
180
* **For Organization/Folder level failures (Org Admin Group or Security
181
Admin Group)**: Run `gcloud organizations add-iam-policy-binding`
182
sequentially for each role in the group.
183
* **For Billing level failures (Billing Admin Group)**: Run `gcloud
184
billing accounts add-iam-policy-binding` sequentially for each role in
185
the group.
186
187
3. **Halt on Remediation Failure**:
188
189
* If the grant commands succeed, immediately retry the failed deployment
190
command.
191
* If any of the grant commands fail (e.g., due to lack of `setIamPolicy`
192
admin rights), **halt execution** and instruct the user to ask their
193
Organization/Billing Administrator to manually grant the entire
194
administrative group of roles.
195
196
#### Phase-Specific Remediation Mapping
197
198
* **Phase 3: Security Guardrails (Org Policies)**:
199
* If `gcloud org-policies set-policy` fails: Attempt to grant the entire
200
**Organization Admin Group** (9 roles) at the organization level.
201
* **Phase 4: Resource Hierarchy (Folders & Projects)**:
202
* If `gcloud resource-manager folders create` or `gcloud projects create`
203
fails: Attempt to grant the entire **Organization Admin Group** (9
204
roles) at the organization level.
205
* **Phase 4: Billing Link**:
206
* If `gcloud billing projects link` fails: Attempt to grant the entire
207
**Billing Admin Group** (3 roles) at the billing account level, and
208
ensure the active identity is granted the **Organization Admin Group**
209
(which contains `roles/billing.user`) at the organization level.
210
* **Phase 5: Centralized Logging & Monitoring**:
211
* If `gcloud logging sinks create` fails at org level: Attempt to grant
212
the entire **Logging/Monitoring Admin Group** (2 roles:
213
`roles/logging.admin`, `roles/monitoring.admin`) and the **Security
214
Admin Group** (9 roles) at the organization level.
215
216
### Phase 3: Security Guardrails (Org Policies)
217
218
Apply 17 baseline security controls at the organization root.
219
220
> [!CAUTION] Applying `iam.allowedPolicyMemberDomains` first can lock out the
221
> deployment identity if it resides in an unallowed domain. Ensure the
222
> deployment identity is safe before enforcing this policy.
223
224
1. Generate the YAML configuration files for the 17 policies. Refer to the
225
[Organization Policies Reference](references/org-policies.md) for the exact
226
YAML templates for both Boolean and List constraints.
227
2. Apply each organization policy sequentially using the `gcloud org-policies`
228
tool:
229
230
```bash
231
gcloud org-policies set-policy [POLICY_FILE_NAME].yaml
232
```
233
234
### Phase 4: Resource Hierarchy
235
236
#### 1. Folder Creation
237
238
Check if target folders exist to avoid duplication. The agent must check for all
239
4 folders: for any folder that already exists (e.g., if `Common` or `Production`
240
are already present), the agent must locate and reuse them; for any folder that
241
is missing (e.g., if `Non-Production` or `Development` are not present), the
242
agent must proceed to sequentially create them:
243
244
> [!IMPORTANT] When explaining how existing resources (folders and projects) are
245
> handled to prevent duplication, the agent **must** explicitly name the
246
> remaining missing folders (`Non-Production` and `Development`) and confirm
247
> that it will proceed to sequentially create only these missing folders and
248
> projects.
249
250
```bash
251
# Check and Create "Common" Folder
252
gcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter="display_name=Common"
253
# If not present:
254
gcloud resource-manager folders create --display-name="Common" --organization=[ORGANIZATION_ID]
255
256
# Check and Create "Production" Folder
257
gcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter="display_name=Production"
258
# If not present:
259
gcloud resource-manager folders create --display-name="Production" --organization=[ORGANIZATION_ID]
260
261
# Check and Create "Non-Production" Folder
262
gcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter="display_name=Non-Production"
263
# If not present:
264
gcloud resource-manager folders create --display-name="Non-Production" --organization=[ORGANIZATION_ID]
265
266
# Check and Create "Development" Folder
267
gcloud resource-manager folders list --organization=[ORGANIZATION_ID] --filter="display_name=Development"
268
# If not present:
269
gcloud resource-manager folders create --display-name="Development" --organization=[ORGANIZATION_ID]
270
```
271
272
#### 2. Project Creation and Billing Link
273
274
Check if target projects already exist in the folders by matching their display
275
names. If not present, generate a shared 8-character random suffix (e.g.,
276
`ab12cd34`) and create the projects sequentially, linking billing and enabling
277
APIs immediately:
278
279
```bash
280
# Check if "central-logging-monitoring" project exists in Common folder
281
gcloud projects list --filter="parent.id=[COMMON_FOLDER_ID] AND parent.type=folder AND name=central-logging-monitoring"
282
283
# If not present: Create, link billing, and enable APIs
284
gcloud projects create logging-[SUFFIX] --name="central-logging-monitoring" --folder=[COMMON_FOLDER_ID]
285
gcloud billing projects link logging-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]
286
gcloud services enable compute.googleapis.com logging.googleapis.com monitoring.googleapis.com --project=logging-[SUFFIX]
287
288
# Check if "production" project exists in Production folder
289
gcloud projects list --filter="parent.id=[PRODUCTION_FOLDER_ID] AND parent.type=folder AND name=production"
290
291
# If not present: Create, link billing, and enable APIs
292
gcloud projects create prod-[SUFFIX] --name="production" --folder=[PRODUCTION_FOLDER_ID]
293
gcloud billing projects link prod-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]
294
gcloud 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]
295
296
# Check if "non-production" project exists in Non-Production folder
297
gcloud projects list --filter="parent.id=[NON_PRODUCTION_FOLDER_ID] AND parent.type=folder AND name=non-production"
298
299
# If not present: Create, link billing, and enable APIs
300
gcloud projects create non-prod-[SUFFIX] --name="non-production" --folder=[NON_PRODUCTION_FOLDER_ID]
301
gcloud billing projects link non-prod-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]
302
gcloud 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]
303
304
# Check if "development" project exists in Development folder
305
gcloud projects list --filter="parent.id=[DEVELOPMENT_FOLDER_ID] AND parent.type=folder AND name=development"
306
307
# If not present: Create, link billing, and enable APIs
308
gcloud projects create dev-[SUFFIX] --name="development" --folder=[DEVELOPMENT_FOLDER_ID]
309
gcloud billing projects link dev-[SUFFIX] --billing-account=[BILLING_ACCOUNT_ID]
310
gcloud 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]
311
```
312
313
> [!NOTE] **Agentic Parallelism Option**: While the manual runbook enforces
314
> sequential project execution to avoid terminal race conditions, an AI agent
315
> with multi-agent orchestration capability may optionally spawn subagents to
316
> provision the 4 projects in parallel once folder IDs are resolved.
317
318
### Phase 5: Centralized Logging and Monitoring
319
320
Configure centralized audit logging and cross-project monitoring scope in the
321
`logging-[SUFFIX]` project.
322
323
Refer to the
324
[Centralized Logging and Monitoring Reference](references/logging-monitoring.md)
325
for the detailed step-by-step commands to:
326
327
1. Create the central log bucket.
328
2. Create the organization-wide log sink.
329
3. Grant required IAM permissions to the log sink.
330
4. Configure the cross-project monitoring metrics scope.
331
332
--------------------------------------------------------------------------------
333
334
## Validation Logic & Checklist
335
336
Evaluate the deployment against the following verification checks:
337
338
- [ ] **Security Policies**: Run `gcloud org-policies list
339
--organization=[ORGANIZATION_ID]` and verify all 17 target policies are
340
enforced or correctly configured.
341
- [ ] **Resource Folders**: Verify folders `Common`, `Production`,
342
`Non-Production`, and `Development` exist under the organization root.
343
- [ ] **Billing Linkage**: Run `gcloud billing projects list` and assert that
344
all 4 newly created projects are linked to your billing account.
345
- [ ] **Log Bucket & Retention**: Verify the log bucket `[ORG_NAME]-logging`
346
exists in project `logging-[SUFFIX]`, is located in `global`, and has a
347
retention period of exactly 30 days.
348
- [ ] **Log Sink Routing**: Run `gcloud logging sinks describe` at the
349
organization level and confirm the sink routes cloud audit logs to the
350
global bucket and holds standard `writerIdentity` credentials.
351
- [ ] **Metrics Scope Linkage**: Run `gcloud beta monitoring metrics-scopes
352
describe` and assert that the `dev`, `non-prod`, and `prod` projects appear
353
in the monitored list of the central `logging` project.
354
355
--------------------------------------------------------------------------------
356
357
## Links
358
359
* [Google Cloud Resource Hierarchy Documentation](https://cloud.google.com/resource-manager/docs/creating-managing-organization)
360
* [Google Cloud Organization Policies Overview](https://cloud.google.com/resource-manager/docs/organization-policy/overview)
361
* [Centralized Audit Logging Best Practices](https://cloud.google.com/architecture/security-foundations/logging-monitoring)
362
* [Cloud Monitoring Metrics Scopes Configuration](https://cloud.google.com/monitoring/settings/multiple-projects)
363
* [Gcloud Logging Sinks CLI Reference](https://cloud.google.com/sdk/gcloud/reference/logging/sinks)
364
* [Google Cloud Landing Zones Guide](https://docs.cloud.google.com/architecture/landing-zones)
365
* [Google Cloud Security Foundations Blueprint](https://docs.cloud.google.com/architecture/blueprints/security-foundations)
366

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…