feat: opt-in published Terraform modules from approved sources (iteration 8)
Infrastructure code is plain resources by default. An Execution may opt in with terraform_modules; the deployment default is TERRAFORM_MODULES, off. - A module is accepted only from the registry namespaces the provider bundle lists (terraform-google-modules), at one exact version. Any other source is refused before Terraform runs; until now nothing stopped generated code naming any source for terraform init to download. - terraform_module looks up a module's inputs, outputs and submodules from the registry and says when it cannot be used with the pinned provider. - skills/google-cloud-iac-modules: when a module fits, and four modules with examples a test validates against hashicorp/google 8.6.0. - Opted in, the IaC author and validator get the Skill and the lookup. Not opted in, they get neither and a module block is refused in code. - A Change request follows its Baseline. execution.json records the choice. - case-07 runs case 03's request with modules opted into. Azure (aztfm) and AWS (terraform-aws-modules) sources are recorded in the plan for when those Cloud providers are added. No case has run with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -468,5 +468,78 @@
|
||||
"require": "\"?cost[-_]centre\"?\\s*="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "case-07-approved-modules",
|
||||
"name": "Internal booking web application, with published Terraform modules opted into",
|
||||
"workflow_request": "Design an internal web application on Google Cloud for staff to book meeting rooms and equipment, backed by a managed relational database, available only to employees signed in with the corporate identity provider, with application secrets kept out of code and configuration.",
|
||||
"required_products": [
|
||||
"Cloud Run",
|
||||
"Cloud SQL",
|
||||
"Secret Manager"
|
||||
],
|
||||
"scripted_answers": [
|
||||
[
|
||||
"region|location|geograph",
|
||||
"A single region, europe-west1 (Belgium). All users are in the EU."
|
||||
],
|
||||
[
|
||||
"user|staff|employee|how many|concurren|traffic|volume|scale|peak|requests per|rps",
|
||||
"About 4,000 employees; 300 concurrent users at the 09:00 peak, around 20 requests per second."
|
||||
],
|
||||
[
|
||||
"availability|uptime|sla|rto|rpo|disaster|recover|backup",
|
||||
"99.5% during business hours (07:00-19:00 CET). RTO 4 hours, RPO 1 hour. Daily backups kept 14 days."
|
||||
],
|
||||
[
|
||||
"latency|response time|performance",
|
||||
"Pages should load within 1 second at p95."
|
||||
],
|
||||
[
|
||||
"identity|sign.?in|login|sso|auth|idp|access",
|
||||
"Employees sign in with Google Workspace accounts; no access from outside the company. Admins are a Google group."
|
||||
],
|
||||
[
|
||||
"security|compliance|encrypt|privacy|gdpr|secret|credential|password",
|
||||
"GDPR applies to employee names and emails. Google-managed keys are fine. Database passwords and API keys must live in a secrets store and rotate every 90 days."
|
||||
],
|
||||
[
|
||||
"data|database|schema|relational|postgres|mysql|size|storage",
|
||||
"PostgreSQL. Under 20 GB of data in the first three years; bookings, rooms, equipment and audit history."
|
||||
],
|
||||
[
|
||||
"cost|budget|spend",
|
||||
"Under 600 EUR a month; the database can be small."
|
||||
],
|
||||
[
|
||||
"current|existing|today|on-prem|migrat|legacy",
|
||||
"Bookings are kept in a shared spreadsheet today; there is no data to migrate."
|
||||
],
|
||||
[
|
||||
"depend|integrat|calendar|email|notif|downstream|upstream",
|
||||
"Send booking confirmation emails through the existing SMTP relay; no calendar integration in phase one."
|
||||
],
|
||||
[
|
||||
"operat|monitor|logging|alert|team|support|deploy|ci|pipeline",
|
||||
"Two developers own it, deploy containers from Cloud Build with Terraform, and want Cloud Monitoring alerts to a Google Chat space."
|
||||
],
|
||||
[
|
||||
"network|vpc|private|internet|egress|ingress",
|
||||
"No public database endpoint; the database must use private IP only."
|
||||
],
|
||||
[
|
||||
"sustainab|carbon",
|
||||
"No specific requirement."
|
||||
],
|
||||
[
|
||||
"retention|audit|archive|delete",
|
||||
"Keep booking history 2 years, then delete; keep audit logs 1 year."
|
||||
],
|
||||
[
|
||||
"approve|confirm|proceed|look right|any changes|happy",
|
||||
"Approved. Please proceed."
|
||||
]
|
||||
],
|
||||
"terraform_modules": true
|
||||
}
|
||||
]
|
||||
|
||||
@@ -71,6 +71,8 @@ class CaseSpec:
|
||||
change: str = ""
|
||||
# Overlay Skills the case's Executions name (ADR-0004).
|
||||
overlay_skills: tuple[str, ...] = ()
|
||||
# Whether the case's Executions opt into published Terraform modules.
|
||||
terraform_modules: bool = False
|
||||
# What the infrastructure code must and must not contain, as regular
|
||||
# expressions over all of it: how a case checks that standards from an overlay
|
||||
# Skill reached the code. Each is {"name", "require"} or {"name", "forbid"}.
|
||||
@@ -118,6 +120,7 @@ def load_cases(path: Path) -> list[CaseSpec]:
|
||||
thresholds=dict(item.get("thresholds", {})),
|
||||
change=str(item.get("change", "")),
|
||||
overlay_skills=tuple(item.get("overlay_skills", ())),
|
||||
terraform_modules=bool(item.get("terraform_modules", False)),
|
||||
code_standards=tuple(item.get("code_standards", ())),
|
||||
)
|
||||
for item in json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
@@ -132,6 +132,7 @@ async def run_with_scripted_user(
|
||||
allow_cloud_read=False,
|
||||
execution_id=execution_id,
|
||||
overlay_skills=case.overlay_skills,
|
||||
terraform_modules=case.terraform_modules,
|
||||
)
|
||||
for _ in range(max_user_turns):
|
||||
if interaction.status != "awaiting_user" or interaction.prompt is None:
|
||||
@@ -194,6 +195,7 @@ async def run_case(
|
||||
execution_id=f"{execution_id}-base",
|
||||
scripted_answers=case.scripted_answers,
|
||||
overlay_skills=case.overlay_skills,
|
||||
terraform_modules=case.terraform_modules,
|
||||
)
|
||||
baseline_tokens = token_report(adk_runtime.usage)["total"].get("total")
|
||||
baseline_seconds = round(time.monotonic() - started, 1)
|
||||
@@ -208,6 +210,7 @@ async def run_case(
|
||||
execution_id=execution_id,
|
||||
scripted_answers=case.scripted_answers,
|
||||
overlay_skills=case.overlay_skills,
|
||||
terraform_modules=case.terraform_modules,
|
||||
baseline=base.execution_id,
|
||||
)
|
||||
elif case.interactive:
|
||||
@@ -223,6 +226,7 @@ async def run_case(
|
||||
execution_id=execution_id,
|
||||
scripted_answers=case.scripted_answers,
|
||||
overlay_skills=case.overlay_skills,
|
||||
terraform_modules=case.terraform_modules,
|
||||
)
|
||||
elapsed = time.monotonic() - started
|
||||
write_progress()
|
||||
@@ -237,6 +241,9 @@ async def run_case(
|
||||
binary=settings.TERRAFORM_BINARY,
|
||||
timeout_seconds=settings.TERRAFORM_TIMEOUT_SECONDS,
|
||||
plugin_cache_dir=settings.terraform_plugin_cache(),
|
||||
module_namespaces=bundle.terraform_module_namespaces
|
||||
if case.terraform_modules
|
||||
else (),
|
||||
)
|
||||
result = await score_execution(
|
||||
case,
|
||||
|
||||
Reference in New Issue
Block a user