Loading...
Loading...
Generate preventive Well-Architected guardrails — AWS Config rules, Service Control Policies, permission boundaries, CloudWatch alarms, and IaC policy checks (CDK Aspects, cfn-guard, OPA/Sentinel) — plus an optional governance steering doc, so a workload stays aligned with Well-Architected best practices over time instead of being assessed once. Use when the user wants to enforce best practices in CI, prevent insecure or non-compliant configurations from shipping, detect configuration drift, codify the fixes from a Well-Architected review as ongoing controls, or capture standards as an always-on steering file for their AI coding agent.
npx skill4agent add aws-samples/sample-well-architected-skills-and-steering wa-guardrailsI can generate guardrails to keep your workload Well-Architected. Let me know:
- Workload name and code packages/directories (IaC, CI/CD configs)
- IaC dialect: CDK (which language), CloudFormation, Terraform, SAM, or mixed
- Source of controls: a prior
or assessment output, specific concerns, or "scan and propose"/aws-well-architected-framework-review- Enforcement points available: CI pipeline (which one), AWS Organizations/SCPs, AWS Config, account-level admin — so controls target what you can actually deploy
- Pillars to prioritize (optional; default: Security and Reliability)
cfn-guardcfn-lintSEC 8REL 9s3-bucket-server-side-encryption-enableds3-bucket-public-read-prohibitediam-policy-no-statements-with-admin-access0.0.0.0/0rds-multi-az-supportdynamodb-pitr-enableddb-instance-backup-enabledcfn-guardDeletionProtection# guardrails/config-rules.yaml
Resources:
S3EncryptionEnabled: # 🔍 Detective — flags any S3 bucket without SSE
Type: AWS::Config::ConfigRule
Properties:
ConfigRuleName: s3-bucket-server-side-encryption-enabled
Source: { Owner: AWS, SourceIdentifier: S3_BUCKET_SERVER_SIDE_ENCRYPTION_ENABLED }// guardrails/no-open-sg.aspect.ts
import { IAspect, Annotations } from "aws-cdk-lib";
import { CfnSecurityGroupIngress } from "aws-cdk-lib/aws-ec2";
import { IConstruct } from "constructs";
// 🛡️ Preventive — fails `cdk synth` on 0.0.0.0/0 ingress to non-web ports
export class NoOpenIngress implements IAspect {
visit(node: IConstruct): void {
if (node instanceof CfnSecurityGroupIngress &&
node.cidrIp === "0.0.0.0/0" && ![80, 443].includes(Number(node.fromPort))) {
Annotations.of(node).addError(`SEC 5: security group open to 0.0.0.0/0 on port ${node.fromPort}`);
}
}
}# guardrails/reliability.guard
# 🛡️ Preventive — blocks RDS instances without Multi-AZ + deletion protection
AWS::RDS::DBInstance {
Properties { MultiAZ == true DeletionProtection == true }
}# Well-Architected Guardrails: {Workload Name}
## Summary
- **IaC dialect**: {CDK/CloudFormation/Terraform/SAM}
- **Enforcement points used**: {CI / Config / SCP / alarms}
- **Source**: {prior review / standalone scan}
- **Controls generated**: {N} ({P} preventive, {D} detective) across {pillars}
## Controls by pillar
### {Pillar} — {WA Question/BP ID}
- **Control**: {name} | 🛡️ Preventive / 🔍 Detective | Enforcement: {CI / Config / SCP / alarm}
- **Blocks/flags**: {what, and why it matters}
- **File**: `{path}`
```{lang}
{ready-to-commit snippet}| Order | Control | Enforcement | Risk of false-positive | Notes |
|---|---|---|---|---|
| {Start in warn/log mode for preventive CI checks and SCPs, then promote to block once clean.} |
## Step 6: Offer a governance steering doc
Beyond machine-enforced controls, offer to capture the same standards as a **human- and agent-readable governance doc** — the prose counterpart to the guardrails. This is useful for the standards a control can't fully express (design conventions, review expectations) and for teams that want an always-on policy their AI coding agent will follow.
Generate it on request as a steering file the agent loads automatically (e.g. `.kiro/steering/`, `CLAUDE.md`, `.cursor/rules/`), structured as:
```markdown
# {Workload} — Well-Architected Guardrails (Governance)
## Enforced automatically
{One line per machine control, linking the rule file and its WA BP ID — so readers know what is already gated in CI/Config.}
## Conventions to follow (not auto-enforced)
- {Pillar} — {convention}, because {WA BP ID rationale}. {How a reviewer/agent checks it.}
## When proposing or reviewing changes to this workload
- {Standing instruction, e.g. "new data stores MUST set encryption + backups before merge (SEC 8 / REL 9)"}Would you like me to:
- Generate the CI workflow wiring (GitHub Actions / CodePipeline step) to run the policy checks?
- Produce a governance steering doc (
/CLAUDE.md/.cursor/rules/) capturing these standards for your AI agent?.kiro/steering/- Add auto-remediation to a detective Config rule (with safety review)?
- Fix the existing violations these guardrails would block (remediate the current code)?
- Tighten a control from warn mode to block mode?
blockDenycfn-guard