962ba24379
PLAN stage. P58 fixes the 4-VPC bug: adds a single shared VPC to
terraform/platform, drops the vpc child from the microservice composition
(references the platform VPC via data source), and makes state keys
env-aware (spike/{id}/{env}/terraform.tfstate — stable across lifecycle).
5 tasks: platform VPC, composition update, resolver environment passthrough,
adapter state key + data block emission, tests + regression.
---ci---
project: acdl
phase: P58
milestone: v1.11
status: plan
---/ci---
3.7 KiB
3.7 KiB
phase, name, milestone, requirements, wave, depends_on
| phase | name | milestone | requirements | wave | depends_on | ||
|---|---|---|---|---|---|---|---|
| P58 | single-platform-vpc-deterministic-state | v1.11 |
|
1 |
|
P58 — Single Platform VPC + Deterministic State Keys
Phase: P58
Milestone: v1.11 (RESTART)
Requirement: REQ-126
Wave: 1 (foundation — the 4-VPC bug fix)
Branch: milestone/v1.11-restart → phase/p58-platform-vpc-state
Goal
- Add a single shared VPC to
terraform/platform/main.tf(VPC + 2 subnets + IGW + route table + ECS security group). Output vpc_id, subnet_ids, ecs_security_group_id. - Drop the
vpcchild from the microservice composition; reference the platform VPC via adata_sourcesblock. The alb + service children wire to the platform VPC, not an inline VPC. - Fix the state key to be env-aware:
spike/{stack_name}/{environment}/terraform.tfstate. Same contract+env always hits the same state key → terraform modifies, never duplicates. - The adapter emits
data "terraform_remote_state" "platform"+data "aws_vpc"blocks when a stack references platform-owned resources.
Tasks (single wave)
Task 1 — Platform VPC in terraform/platform/main.tf (data-engineer)
Add to terraform/platform/main.tf:
aws_vpc.acdl_shared(10.0.0.0/16)- 2
aws_subnetacross 2 AZs (10.0.1.0/24, 10.0.2.0/24) aws_internet_gateway+aws_route_table+ associationsaws_security_group.ecs(ingress on port 80, egress all)- Outputs:
vpc_id,subnet_ids(comma-separated),ecs_security_group_id
Task 2 — Microservice composition: drop vpc, add data_sources (backend-engineer)
Update modules/l2/microservice/composition.json:
- Remove
{"id": "vpc", "module": "vpc@1.0.0"}from children. - Add a
data_sourcesblock:{"name": "platform_vpc", "type": "terraform_remote_state", "source": "platform"}. - Update wires:
vpc.outputs.subnet_ids→platform_vpc.outputs.subnet_ids. - Add a wire for
platform_vpc.outputs.vpc_id→alb.inputs.vpc_id. - Add a wire for
platform_vpc.outputs.ecs_security_group_id→service.inputs.security_group.
Task 3 — Contract resolver: pass environment + handle data_sources (backend-engineer)
Update core/contract_resolver.py:
- Add
"environment": env_nameto the stack instance'sstackblock (line 568-572). - Handle
data_sourcesin the composition: resolve data source references to stack-level pseudo-resources that the adapter can emit asdatablocks.
Task 4 — Adapter: env-aware state key + data block emission (backend-engineer)
Update adapters/terraform/adapter.py:
- State key:
spike/{stack_name}/{environment}/terraform.tfstate(read environment fromstack_instance["stack"]["environment"]). - When a resource input references a platform data source (e.g.
ref:platform_vpc.subnet_ids), emit adata "terraform_remote_state" "platform"block + pass the data source output as the module argument.
Task 5 — Tests + offline regression
- Update
tests/test_adapter.py: assert the state key is env-aware. - Update
tests/test_pipeline.py: the microservice contract now resolves without a vpc resource. pytest tests/ -m "not slow"— all pass.run_platform.sh --check-only contracts/microservice.yml— exits 0.
Success Criteria (phase gate)
terraform/platform/main.tfhas a VPC + subnets + IGW + route table + SG.contracts/microservice.ymlresolution produces NOaws:ec2:vpcresource.- Two contract applies (dev + prod) → ONE VPC, two state keys
(
spike/msvc/dev/,spike/msvc/prod/), two ECS services. - Same contract+env re-applied → same state key → terraform modifies, never duplicates.
pytest tests/ -m "not slow"— all pass.run_platform.sh --check-only contracts/microservice.yml— exits 0.