Create Policies with AI
Describe a FinOps rule in plain English and SOFE generates a valid policy YAML automatically.
How It Works
You type: "Alert when S3 buckets don't have encryption enabled"
↓
AI generates valid SOFE policy YAML:
↓
apiVersion: sofe/v1
kind: Policy
metadata:
name: s3-encryption-required
description: "Detect S3 buckets without encryption enabled"
severity: high
spec:
scope:
resource_types: ["aws.s3"]
rule:
metric: encryption_enabled
operator: "=="
threshold: 0
message: "encryption_enabled = {value} (threshold: =={threshold})"
recommendation: "Enable default encryption (SSE-S3 or SSE-KMS)"
↓
You review → Save → Policy is yoursPrerequisites
- AI Provider configured (see guide)
- Recommend a ≥30B model (Claude, Llama 70B, Gemma 31B) for accurate YAML generation
Step-by-Step
- 1. Go to platform.sofe.dev/policies/create
- 2. Type your policy description in plain English (min 10 characters)
- 3. Click "🧠 Generate Policy" — wait 3-5 seconds
- 4. Review the generated YAML (shown in green preview)
- 5. Click "💾 Save Policy" to store it
- 6. Find it in /catalog → Policies tab → "My Custom Policies"
Example Prompts
"Alert when EC2 instances have CPU below 5% (idle resources)"
"Require all S3 buckets to have lifecycle rules configured"
"Flag any resource missing the costcenter tag"
"Detect RDS instances with zero connections (unused databases)"
"Alert when NAT Gateway monthly cost exceeds $100"
"Ensure secrets in Secrets Manager have rotation enabled"
Available Metrics
Your policy can only use metrics that SOFE collectors actually measure. Current metrics:
avg_cpu_utilization
monthly_cost
running_days
has_tag:owner
has_tag:env
has_tag:costcenter
invocations
connections
attached
rotation_enabled
encryption_enabled
has_lifecycle_rules
compression_enabled
throttle_configured
If you request a policy for a metric that doesn't exist (e.g., "spot instance price"), the AI will respond with an error explaining the limitation.
Validation
Generated YAML is validated before showing it to you:
- Must contain
apiVersion: sofe/v1,kind: Policy,spec: - If invalid, AI retries automatically (up to 3 attempts)
- If still invalid after 3 attempts, you get an error message
Saved Policies
Saved policies appear in:
- /catalog → Policies tab → "My Custom Policies" section
- Stored in your Firestore account (private to you)
- Coming soon: Custom policies will be included in cloud evaluations automatically
Limitations
- Only available metrics can be used (see list above)
- Custom policies not yet included in scheduled evaluations (coming soon)
- Each generation counts as 1 AI call (rate limited)
- Weaker models (<30B) may generate invalid YAML — use recommended models