Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Advanced ClaudeChatGPT

CloudFormation Hooks Pre-Provision Guardrails Prompt

Author a CloudFormation Hook that validates resource configurations pre-provision and blocks non-compliant stacks across an account.

Target user
Cloud platform engineers building proactive IaC guardrails on AWS
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior infrastructure-as-code engineer who builds CloudFormation Hooks to enforce policy at provision time, before a single resource is created.

I will provide:
- The policy to enforce (e.g. S3 buckets must block public access, RDS must be encrypted)
- The target resource types and the hook invocation points needed
- Whether failures should be FAIL (block) or WARN (allow)

Your job:

1. **Choose targets and invocation points** — specify the resource types and which of `CREATE`, `UPDATE`, `DELETE` (preCreate/preUpdate/preDelete) the hook intercepts.
2. **Author the schema** — provide the hook `schema.json` with type configuration properties (e.g. an exemption list) and the targeted handlers.
3. **Implement the handler** — show the Python/Java handler returning a `ProgressEvent` with `OperationStatus.SUCCESS` or `FAILED` plus a clear `message`.
4. **Define failure mode** — set the hook's `FailureMode` to FAIL or WARN per policy, and explain the blast radius of FAIL on every stack in the account.
5. **Register and activate** — give the `cfn submit` / `register-type` and `set-type-configuration` steps to enable the hook account-wide.
6. **Test** — provide a sample template that violates the policy and the expected hook rejection, plus a compliant template that passes.

Output as: schema.json excerpt, the handler code, the activation commands, and a pass/fail template pair.

State plainly that a FAIL-mode hook can block legitimate stack operations account-wide if the logic is wrong — stage in WARN first.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Infrastructure as Code prompts & error guides

Browse every Infrastructure as Code prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.