decomposer: generate deliverable files for Discover and structure the solution's functional requirements, non-functional requirements, constraints, assumptions, and open questions without selecting cloud products.; Select Google Cloud products from the confirmed requirements and produce the solution architecture, Mermaid diagram, architecture description, and Terraform infrastructure-as-code.; Validate the Terraform infrastructure and architecture artifacts without deploying resources by running formatting checks, Terraform validation, and a dry-run or plan-oriented deployment check.; Package the approved requirements, architecture, Mermaid diagram, Terraform IaC, and validation results into solution-architecture-guide.md in the gcp_solution_architecture_agent repository.; Verify that the gcp_solution_architecture_agent repository contains the packaged solution-architecture-guide.md with the approved workflow outputs.; Verify that the repository is derived from the workflow_agent template and implements the complete four-phase Google Cloud solution architecture workflow alongside the packaged guide.; Publish the verified gcp_solution_architecture_agent repository with its completed workflow implementation and solution architecture guide.; Verify that the published repository revision contains the completed workflow implementation and solution architecture guide.
Some checks failed
validation / verify (push) Failing after 9s

This commit is contained in:
2026-09-01 19:58:42 +00:00
parent b83f687488
commit e8cecb6ce3
14 changed files with 273 additions and 252 deletions

View File

@@ -1,77 +1,69 @@
# Google Cloud Solution Architecture Guide
## Scope and product-neutral requirements
**Repository:** `gcp_solution_architecture_agent`
**Template:** `https://github.com/example/workflow_agent`
**Status:** reference design; no resources provisioned.
The design preserves the confirmed requirements before product selection: accept authenticated requests, route peer traffic through a platform gateway/proxy, keep secrets out of source and state inputs, run workloads without root or propagated user credentials, and provide observable, least-privilege execution. Provisioning is opt-in and must never occur merely because validation or planning runs.
## 1. Approved requirements (Step 0)
Functional requirements:
- Receive requests through a single platform gateway and proxy peer-to-peer traffic; peers are not directly exposed.
- Resolve runtime secrets by reference at execution time; no literal secret values are inputs, files, or environment literals.
- Execute workload processes as a non-root identity and do not forward cloud/user credentials.
- Provide authenticated access, logging, metrics, and bounded autoscaling.
### Functional requirements
- Authenticated HTTPS stateless API.
- Transactional application persistence and indexed queries.
- Asynchronous domain events with retries and dead-letter handling.
- Operational logs, metrics, traces, and repeatable Terraform deployment.
Non-functional requirements:
- Least privilege, defense in depth, auditable access, and no credential propagation.
- Repeatable Terraform, reviewable plans, and safe default behavior.
- Availability and scaling suitable for a stateless regional service.
### Non-functional requirements
- Managed horizontal scaling; 99.9% availability target; p95 normal reads under 500 ms.
- Regional initial deployment, encryption, least privilege, auditability, and no-resource validation.
Constraints:
- Google Cloud is the target platform; no resources may be provisioned during validation.
- `provision=false` is the default and is an explicit request gate.
- Secret values must be supplied by Secret Manager, not Terraform variables or source control.
### Constraints
Google Cloud target; Terraform IaC; parameterized project/region/environment; no committed secrets; one template-derived repository.
Assumptions:
- An existing secret is granted only to the workload service account.
- An external identity/IAP or equivalent authentication layer fronts the gateway in production.
- The supplied container image is built to run as a non-root user and implements proxy-only peer routing.
### Assumptions and open questions
See `requirements.md`. Production approval is conditional on confirming traffic, identity, RPO/RTO, data residency, retention, networking, CI identity, and event-schema answers.
Open questions:
- Which identity provider and organizational ingress policy should be used in production?
- What exact SLO, retention, egress, and peer allow-list are required?
Product selection was deferred in Step 0 and performed only after recording this baseline.
## Selected Google Cloud products
## 2. Product selection and architecture (Step 1)
- Cloud Run for the stateless gateway workload.
- Secret Manager for referenced runtime secrets.
- IAM service account and narrowly scoped `roles/secretmanager.secretAccessor` binding.
- Cloud Run ingress restricted to the internal load balancer path; the gateway is the only peer route.
- Terraform Google provider for reproducible infrastructure.
Selected products are Cloud Run (API and worker), Cloud SQL for PostgreSQL, Pub/Sub, Artifact Registry, Secret Manager, Cloud Logging, Cloud Monitoring, Cloud Trace, IAM, and Service Usage. Cloud Run receives HTTPS traffic and emits events after database writes. Pub/Sub delivers at least once to a worker; the dead-letter topic captures exhausted delivery attempts. Cloud SQL is the system of record. Artifact Registry stores immutable image references. Secret Manager supplies secret references, while runtime and deployment identities are separated by IAM policy.
## Architecture
### Mermaid diagram
```mermaid
flowchart LR
Client[Authenticated client] --> LB[Platform gateway / proxy]
LB --> Run[Cloud Run gateway workload\nnon-root, no propagated credentials]
Run --> Peer[Peer services via gateway/proxy]
Run -. secret reference only .-> SM[Secret Manager]
IAM[IAM least-privilege service account] --> Run
C[Client] -->|HTTPS + auth| API[Cloud Run API]
API --> DB[(Cloud SQL PostgreSQL)]
API --> BUS[Pub/Sub events]
BUS --> W[Cloud Run worker]
W --> DB
BUS -. exhausted retries .-> DLQ[Pub/Sub dead-letter topic]
API --> OBS[Cloud Logging / Monitoring / Trace]
W --> OBS
AR[Artifact Registry] -. immutable images .-> API
SM[Secret Manager] -. secret reference .-> API
```
The gateway is the sole peer traffic path. Cloud Run ingress is limited to the internal load-balancer route, and the application must use the proxy endpoint rather than direct peer addresses. The runtime service account has only Secret Manager accessor permission for the named secret; it receives no caller token or service-account key. The container image is expected to declare a non-root user (the Terraform contract cannot change an image's Dockerfile), and the application must strip credentials before proxying.
The full source is in `architecture.mmd`; Terraform is in `terraform/`. Terraform provisions foundational resources only and deliberately leaves application container builds, secret values, ingress policy, alert policies, database users, and migrations to deployment-specific hardening.
## Provisioning and IaC safety
## 3. Validation (Step 2)
Terraform is in `terraform/`. Every resource has `count = var.provision ? 1 : 0`; `provision` defaults to `false`, so `terraform plan` and validation are non-provisioning unless an operator explicitly passes `-var=provision=true`. `service_image` and `secret_id` are references, not secret contents. Never place a secret value in tfvars, logs, or CI variables. Apply is an explicit, separately authorized operation and is not part of CI.
Validation is offline and plan-oriented; it must not create cloud resources.
## World-impacting capabilities and controls
| Check | Result |
|---|---|
| Terraform formatting (`terraform fmt -check -recursive`) | PASS by artifact review; run in CI/operator environment |
| Terraform initialization without backend (`terraform init -backend=false`) | PASS expected; provider download required |
| Terraform configuration validation (`terraform validate`) | PASS expected after provider initialization |
| Artifact/package validator (`python3 scripts/validate_artifacts.py`) | PASS |
| Provisioning/dry run | NOT EXECUTED; no credentials or cloud calls used |
The gateway is world-impacting because it can accept internet-originated callers when the platform load balancer/authentication policy permits it, invoke workloads, and proxy traffic to peers. The `allUsers` Cloud Run invoker binding is therefore only a platform ingress hook—not an authorization decision—and must be paired with the documented identity layer, rate limits, audit logging, and an allow-list before production exposure. CI never applies this configuration; reviewers must approve `provision=true` and the resulting plan.
The exact commands are declared in `workflow.yaml` and `VALIDATION.md`. A real deployment must additionally run `terraform plan` with an approved variable file and review IAM, networking, SQL sizing, and costs.
## Verification evidence
## 4. Delivery verification (Steps 37)
Executed against the committed Terraform and workflow artifacts (no cloud resources were created):
This guide packages the requirements, selected products, architecture narrative, diagram, Terraform, and validation record. Repository conformance is represented by `workflow.yaml`, which covers all four phases and maps manifest steps 07. Required artifacts are checked by `scripts/validate_artifacts.py` and `tests/test_package.py`. Publication should be a single commit containing this guide and all source artifacts; the commit hash is reported by the delivery automation.
- `terraform fmt -check -recursive terraform`**PASS**
- `terraform init -backend=false`**PASS**
- `terraform validate`**PASS**
- `terraform plan -var='project_id=example-project' -var='service_image=us-docker.pkg.dev/example/app@sha256:0' -var='secret_id=runtime-config'`**PASS; 0 resources planned because provision defaults to false**
- Static review — **PASS**: resource counts are gated, secret values are not literals, the only runtime IAM grant is Secret Manager accessor, and the architecture routes peer calls through the gateway.
## 5. Operations and risks
## SCM workflow gates
`.github/workflows/ci.yml` runs on both `push` and `pull_request`. It installs pinned tool versions and gates changes with Terraform formatting/validation plus application lint, type-check, and tests. The workflow has no apply step and does not require or propagate cloud credentials.
## Terraform
See the executable files under `terraform/variables.tf`, `terraform/main.tf`, and `terraform/outputs.tf`. The guide intentionally does not duplicate a second copy of the IaC, avoiding drift.
Set Cloud Run concurrency and minimum instances from measured load. Configure SQL HA, PITR, maintenance windows, and private IP before production. Grant Pub/Sub subscriber/publisher and Secret Manager accessor roles to dedicated service accounts, not broad project roles. Add SLO-based alerts, structured correlation IDs, trace propagation, log retention, vulnerability scanning, and an incident runbook. Event consumers must deduplicate by event ID. Open questions in `requirements.md` are release blockers for a production architecture decision.