/aws-startup-advisor:tf-best-practicesfrom aws-startup-advisor
Provides AWS Terraform best-practice authoring rules and a read-only policy gate for generated infrastructure. Load before writing to get security posture specs, after writing to get a deterministic pass/fail verdict.
Ships in aws-startup-advisor. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A shared authoring guide and verdict producer, not a workflow. It answers two questions for a phase that generates AWS Terraform:
terraform/ follow?"
(the posture rules + the baseline.tf account-hardening spec)terraform/ pass policy?" (a deterministic,
read-only verdict + a machine-readable report)This skill is entered at two touchpoints in the caller's Generate flow, with the caller's own terraform-authoring work in between. The caller states which touchpoint it is at when it loads this skill, and reads the corresponding part:
| Caller context | Load | Why |
|---|---|---|
About to author terraform/ (before writing) | Part 1 → references/security-posture-rules.md | The "what to emit" AWS authoring rules (gate-enforced + authoring-only + compliance-conditional). |
terraform/ written, ready to validate (after writing) | Part 2 → references/terraform-validation.md + run the gate script | The fmt → init → validate → policy protocol and the read-only verdict. |
Everything this skill states is source-cloud-agnostic (pure AWS Terraform). Any GCP/Heroku
detection or artifact reading is the caller's job; where a rule needs a caller-known fact (e.g.
declared compliance frameworks), the caller passes it as a caller-context signal — see
references/security-posture-rules.md § Caller-context signals.
This unit is a verdict producer, never a mutator. Its entire write surface is the JSON verdict it is asked to emit. Specifically it MUST NOT:
.tf file (the caller owns remediation),.phase-status.json or any run-state file (interpreter-owned),The caller (a migration skill's Generate phase) owns: the fix-and-retry loop that edits
the .tf it generated, terraform fmt auto-apply, the retry/skip/abort prompt, the
Phase Completion gate, and every .phase-status.json write. See the consuming skill's
generate phase for how the verdict feeds those decisions.
Consumers:
gcp-to-aws(prose Generate) andheroku-to-aws(DSL Generate). The contract is source-agnostic; each caller wires the two touchpoints in its own Generate idiom — gcp-to-aws as prose steps, heroku-to-aws as a fragment step plus a fail-closed_postconditionsassert enforced by the interpreter.
terraform/)Emit generated Terraform that satisfies the posture in
references/security-posture-rules.md.
These are the "what good AWS Terraform looks like" rules. Following them makes the Part 2 gate pass by construction. This unit does not read the caller's artifacts — it consumes only caller-context signals the caller passes in.
Scope.
security-posture-rules.mdcovers, in three tiers:
- Gate-enforced (Part 2 verifies statically): ALB TLS, no-public-database, RDS + ElastiCache encryption-at-rest, no-public-DB-port ingress, no-public admin/datastore-port ingress, no-wildcard-IAM.
- Authoring-only (not gate-checkable, still required):
deletion_protection, master-password-via-Secrets-Manager, WAF web ACL on internet-facing ALBs, S3 hardening, Fargate/EKS/ECR settings, private-subnet placement, S3 gateway endpoint + NAT cost comment, Bedrock grants scoped to model/profile ARNs, backups, baseline monitoring, one account-wide cost budget per root.- Compliance-conditional (emitted when the caller declares
soc2/pci/hipaa/fedramp): VPC flow logs, S3 access logging, secret rotation, customer-managed KMS.Still the caller's own generation concern (candidates to migrate here later): the account-hardening
baseline.tflayer (CloudTrail, GuardDuty, Config, Security Hub).
terraform/)Run the read-only checker against the generated directory. Resolve the script path relative to
the plugin root ($PLUGIN_ROOT/skills/tf-best-practices/scripts/...), the same convention the
plugin uses for its other scripts:
python3 "$PLUGIN_ROOT/skills/tf-best-practices/scripts/validate-terraform-policy.py" "$TERRAFORM_DIR" --json "$VERDICT_PATH"
$TERRAFORM_DIR — required, caller-supplied: the generated terraform/ directory
(e.g. $MIGRATION_DIR/terraform). This skill never defaults or discovers it — the caller
always passes the path it wrote Terraform to.--json $VERDICT_PATH — optional; writes a machine-readable verdict the caller can merge
into its own validation-report.json.The policy check is one stage of a larger validation flow (fmt → init → validate → policy).
The full protocol — including offline-fallback behavior and how the policy verdict maps into a
validation-report.json — is documented in
references/terraform-validation.md. That protocol is
descriptive: the caller owns the fmt/init/validate execution, the fix-and-retry loop, and
the report write; this unit contributes only the read-only policy stage + verdict shape.
Before infrastructure completion, the caller must run
scripts/validate-terraform-report.py on the saved validation-report.json and
require exit 0. The checker enforces the shared v2 completion contract. Its
RUNTIME_REPORT_OK result does not establish that Terraform ran or passed.
| Exit | stdout | Meaning | Caller does |
|---|---|---|---|
0 | POLICY_OK | posture satisfied | proceed |
1 | POLICY_FAIL | violations present | read violations[], edit the named .tf sites, re-run (caller's retry budget) |
2 | (usage error) | bad path / IO | surface to user; do not treat as pass |
--json){
"check": "policy",
"policy_status": "POLICY_OK | POLICY_FAIL",
"violations": [
{
"check": "policy",
"rule": "alb_https_listener | alb_http_redirect | no_tf_files",
"file": "compute.tf",
"line": 7,
"severity": "error",
"summary": "human-readable violation",
"fix_hint": "concrete remediation the caller can apply"
}
]
}
Each violations[] entry is actionable evidence — file + line + fix_hint tell the
caller exactly what to edit. The caller applies the edit; this unit only reports.
Migration callers can also run the shared read-only
scripts/validate-migration-artifacts.py against their complete migration
directory:
python3 "$PLUGIN_ROOT/skills/tf-best-practices/scripts/validate-migration-artifacts.py" \
"$MIGRATION_DIR" --json "$MIGRATION_DIR/artifact-validation-status.json"
This produces ARTIFACTS_OK, ARTIFACTS_FAIL, or ARTIFACTS_ERROR, separately
from the Terraform policy verdict. The caller must inspect the real exit code
and report; it must not synthesize success. Supported checks cover PostgreSQL
verification control flow, EB/database security-group wiring, GitHub Actions
step references and deployment operations, and literal RDS time windows.
Unsupported structures require review. This is not a general Bash safety proof,
provider validation, or proof that a deployment succeeds.
Heroku callers add --require-postgres-script when PostgreSQL is in the design,
and --require-eb-workflow when GitHub Actions is the selected EB deployment
method. Other callers must not impose those Heroku-specific requirements.
The checker never executes a generated migration script or changes input files
or phase state; only the explicit JSON report path may be written.
For RDS/Aurora generation, scripts/rds_windows.py resolves independent daily
backup and weekly maintenance windows from caller preferences. It rejects
invalid or explicitly conflicting choices rather than silently changing them.
Callers use its actual JSON values when authoring Terraform.
Every rule is fail-open on ambiguity — it fires only on unambiguous, in-block literal
evidence, so a valid stack is never falsely blocked (a POLICY_FAIL is a hard completion gate
for the caller, so a false positive would block a real migration).
Internet-facing ALB TLS posture (an ALB is internet-facing when internal is absent,
false, or variable-driven — fail-safe):
alb_https_listener — must have an HTTPS listener on 443 with certificate_arn and a
forward action.alb_http_redirect — an HTTP :80 listener must redirect to HTTPS, never forward
to targets. Internal ALBs (internal = true) are exempt.Elastic Beanstalk ALBs are invisible to these rules. The ALB rules inspect standalone
aws_lb_listenerblocks. An EB LoadBalanced environment provisions its ALB fromaws_elastic_beanstalk_environmentsettingblocks, which the static checker does not read — so a pure-EB design passes the ALB rules vacuously (no listener to inspect). EB listener/TLS posture is therefore authoring-only, not gate-enforced. (Fixturesgood-heroku-eb-onlyandgood-heroku-eb-singleinstancedocument this;good-heroku-eb-loadbalancedcarries a standalone ALB so the listener rules are exercised on real blocks.)
Managed database exposure & encryption (aws_db_instance, aws_rds_cluster):
rds_not_public — must not set publicly_accessible = true (absent/variable → fail-open).rds_encryption_at_rest — must set storage_encrypted = true; missing or literal false
fires (RDS defaults to unencrypted), variable-driven fails open. S3 is not checked (default
SSE-S3 since Jan 2023).ElastiCache encryption (aws_elasticache_replication_group, Redis aws_elasticache_cluster):
elasticache_encryption_at_rest — a replication group must set
at_rest_encryption_enabled = true; missing or literal false fires, variable-driven fails
open.elasticache_cluster_encryption — a Redis-engine aws_elasticache_cluster (single-node:
engine = "redis", no replication_group_id) must set BOTH at_rest_encryption_enabled = true
and transit_encryption_enabled = true; missing or literal false on either fires,
variable-driven fails open. engine = "memcached" clusters (and variable-driven/absent engine)
are exempt — Memcached does not support these attributes.Security group ingress:
db_sg_no_public_ingress — an inline aws_security_group ingress covering 5432/3306
must not allow 0.0.0.0/0 or ::/0.sg_no_public_admin_ingress — an inline ingress must not open a curated never-public
admin/datastore port (22, 3389, 6379, 11211, 27017, 9200/9300, 5601) to
0.0.0.0/0 or ::/0. Web (80/443) and app/game ports are not flagged; DB ports are
handled by the rule above. Both check cidr_blocks and ipv6_cidr_blocks independently, so a
benign IPv4 list does not mask an open IPv6 one. Both: separate aws_security_group_rule /
aws_vpc_security_group_ingress_rule resources fail open (not correlated).IAM least-privilege (aws_iam_policy, aws_iam_role_policy, aws_iam_group_policy,
aws_iam_user_policy):
no_wildcard_iam — an Allow statement must not use Action/Resource "*".
Three narrow exceptions, for actions AWS defines no resource-level permissions for:
an isolated elasticbeanstalk:CreateStorageLocation statement, an ECS Exec
statement listing only the four ssmmessages channel actions
(CreateControlChannel, CreateDataChannel, OpenControlChannel, OpenDataChannel)
as string literals, and an isolated bedrock-mantle:CallWithBearerToken or bedrock:CallWithBearerToken statement.
Any other action, or any non-literal member (local.x, var.y),
in the same statement disqualifies it.
aws_iam_policy_document data sources and assume-role trust policies fail open.The checker is a zero-dependency static HCL reader (no
terraform init, no provider download) — it runs even when the registry is unreachable. It uses brace-depth matching for nested blocks, so a valid HTTPS listener written with a nestedforward { ... }block is not a false failure.
fixtures/terraform-policy/ holds intentionally-shaped Terraform used by
scripts/test_validate_terraform_policy.py:
bad-http-forward/ — internet-facing ALB that forwards plaintext HTTP → MUST POLICY_FAIL.internal-alb-only/ — internal ALB on HTTP → MUST POLICY_OK (HTTP allowed internally).good-https-redirect/ — the correct pattern → POLICY_OK.These are deliberately non-compliant test data (never deployed). They are excluded from the
repo-wide checkov scan via .checkov.yaml skip-path; do not "harden" them — doing so
breaks the tests that assert the failure paths.
# from skills/tf-best-practices/
uv run --python 3.12 --with pytest python -m pytest scripts/test_validate_terraform_policy.py -q
fixtures/terraform-policy/bad-bedrock-wildcard-resource/iam.tf (opens in a new tab)fixtures/terraform-policy/bad-db-sg-public-quoted-port/vpc.tf (opens in a new tab)fixtures/terraform-policy/bad-db-sg-public/vpc.tf (opens in a new tab)fixtures/terraform-policy/bad-elasticache-cluster-redis-unencrypted/cache.tf (opens in a new tab)fixtures/terraform-policy/bad-elasticache-unencrypted/cache.tf (opens in a new tab)fixtures/terraform-policy/bad-heroku-eb-elasticache/cache.tf (opens in a new tab)fixtures/terraform-policy/bad-http-forward/compute.tf (opens in a new tab)fixtures/terraform-policy/bad-rds-public-brace-in-comment/main.tf (opens in a new tab)fixtures/terraform-policy/bad-rds-public-closing-brace/main.tf (opens in a new tab)fixtures/terraform-policy/bad-rds-public-interpolated-brace/rds.tf (opens in a new tab)fixtures/terraform-policy/bad-rds-public-unencrypted/database.tf (opens in a new tab)fixtures/terraform-policy/bad-sg-public-ipv6/vpc.tf (opens in a new tab)fixtures/terraform-policy/bad-sg-public-ssh/vpc.tf (opens in a new tab)fixtures/terraform-policy/bad-wildcard-iam-listform/security.tf (opens in a new tab)fixtures/terraform-policy/bad-wildcard-iam/security.tf (opens in a new tab)fixtures/terraform-policy/good-bedrock-mantle-bearer/iam.tf (opens in a new tab)fixtures/terraform-policy/good-bedrock-scoped-invoke/iam.tf (opens in a new tab)fixtures/terraform-policy/good-db-sg-scoped/vpc.tf (opens in a new tab)fixtures/terraform-policy/good-elasticache-cluster-memcached/cache.tf (opens in a new tab)fixtures/terraform-policy/good-elasticache-cluster-redis-encrypted/cache.tf (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
terraform, infrastructure-as-code, policy-gate, aws, security-baseline
19 skills in this plugin
/agent-advisorEntry point for AI-agent work on AWS: pick a runtime, plan a migration, and build a POC. Triggers on: which runtime for my agent, AgentCore vs ECS vs EKS vs Lambda, AgentCore vs Lambda MicroVMs, deploy an AI agent on AWS, agent architecture on AWS, is my agent on the right runtime, I have an agent idea what do I build, move/migrate my agents to AWS (including from GCP, Azure or Heroku), agent migration plan, add AgentCore services (memory, gateway, identity, policy, observability) to an agent already on AWS, Temporal on AWS (migrate/run Temporal workers, a service orchestrated by Temporal, Temporal Cloud vs self-hosted). Temporal Workflow code is never rewritten into Step Functions. Requires at least one agentic component; non-agent systems (plain services, batch jobs, HTTP endpoints, non-agent Activities) go to gcp-to-aws / heroku-to-aws / llm-to-bedrock, and self-hosted LLM batch inference to self-hosted-llm-batch-inference. Not for: pure LLM SDK rewrite; per-model pricing; Well-Architected reviews./architect-for-startupsStartup-tailored AWS architecture advice for non-agent workloads, adjusted to stage (pre-revenue through Series B+), team size, runway, and credits. Not for AI agents: deploying one, picking its runtime, or any agentic architecture is agent-advisor. Use when a founder wants guidance or a recommendation rather than code changes: which services to choose, where to host a web app, designing or reviewing an architecture, tenant isolation for a multi-tenant SaaS, stretching credits and controlling cost, or preparing for a fundraise or technical diligence. Scaffolding into the codebase is start-building-for-startups. Do not use for: writing code, Activate / programs / credits lookups (knowledge-base-for-startups), a copy-paste prompt (prompt-library-for-startups), pricing an infrastructure change before it ships (cost-regression-check), self-hosted LLM batch inference (self-hosted-llm-batch-inference), or migration intent (`gcp-to-aws`, `azure-to-aws`, `heroku-to-aws`, `llm-to-bedrock`, `claude-apps-to-bedrock`)./azure-to-awsMigrate Microsoft Azure workloads to AWS. Triggers on: Azure to AWS, move off Azure, AKS to EKS, App Service or Azure VMs to AWS compute, Azure SQL/Database to RDS, Cosmos DB to DynamoDB, Azure OpenAI to Bedrock, Azure cost estimates, or what-if workshops. Discovery uses read-only `az`, Terraform (optional), a Resource Discovery for Azure (RDfA) report, and application code, with optional consent-gated OpenAI, OpenRouter, and Anthropic usage APIs. Runs Discover, Clarify, Design, Estimate, optional repricing, Generate, and Feedback; Clarify gates later phases and Generate is opt-in. Azure billing-export discovery is not implemented. Billing exports, Bicep, and ARM are not implemented; Bicep/ARM-only workspaces halt; use user-stated spend as the infrastructure baseline when needed. Do not use for GCP or Heroku migrations, reverse migrations, general AWS architecture, or Azure-to-Azure refactoring./bedrock-migration-assessmentSource-cloud-neutral assessment of AI/LLM usage for a migration to Amazon Bedrock. Use when the user wants to find which OpenAI (direct or Azure OpenAI), Anthropic, Google/Gemini, or OpenRouter calls their code makes, or already has a provider-neutral ai-workload-profile.json (schema 1.0 or 1.1), and wants to choose and price Bedrock models for it. It scans the code or validates the profile, can measure OpenAI, Anthropic, and OpenRouter usage read-only with the user's consent and an admin or management key, shows a short preview, runs Clarify, designs a Bedrock target, endpoint, and client API per workload, estimates the monthly Bedrock cost against the current provider, and, on opt-in, generates a migration plan with Bedrock clients, a comparison harness, IAM, and a setup script. It needs no infrastructure skill and never edits the user's code. To rewrite SDK calls to Bedrock and get a branch, use llm-to-bedrock; for infrastructure migrations use gcp-to-aws, azure-to-aws, or heroku-to-aws./claude-apps-to-bedrockUse when a person or team wants to move the Claude apps they use, Claude Desktop (Chat, Cowork) and Claude Code, from Anthropic direct to Claude on Amazon Bedrock without losing claude.ai history, for example to pay with Activate credits. Asks whether this is an individual, an IT admin rolling out with Jamf or Intune, or a user on an IT-managed computer, checks the machine read-only, then walks only that person's steps. Imports claude.ai chats and projects with Claude Desktop's Import from Claude wizard and carries history into Claude Code. Triggers on: switch Claude Code or Claude Desktop to Bedrock, CLAUDE_CODE_USE_BEDROCK, keep my claude.ai history, Claude Desktop via Jamf or Intune. Also handles Bedrock model access for those apps. Not for code that calls the Claude API (Anthropic SDK, Messages API, Agent SDK), OpenAI, or Gemini: rewriting it, or model access for it, is llm-to-bedrock; scanning and pricing it is bedrock-migration-assessment. Activate questions: knowledge-base-for-startups./contextual-offers-for-startupsSurfaces a single, genuinely relevant AWS Activate partner offer as optional context AFTER another AWS Startup Advisor skill has finalized its recommendation, plan, or build — never influencing the technical advice. Consulted by architect-for-startups, start-building-for-startups, agent-advisor, gcp-to-aws, heroku-to-aws, and llm-to-bedrock: once their output is final, this skill checks whether a relevant Activate offer exists for what the founder is building or migrating and, if so, appends one quiet, dismissible line with a tracked redeem link. Merit-first (offers never change the recommendation), relevance-gated to what the founder actually surfaced, at most one per response and often none, muteable. Offer content is read live from the sibling knowledge-base-for-startups skill (references/offers.md). Do NOT use for account-specific lookups (credits balance, Activate membership, application status) — send those to https://aws.amazon.com/startups.npx claudepluginhub aws/agent-toolkit-for-aws --plugin aws-startup-advisorOther plugins' skills for the same job