Skip to main content
A Pulumi plan output is technically precise but demanding to read. A wall of + aws_rds_instance.db, (update) aws_s3_bucket_v2.media, - aws_lambda_function.old_api tells you what’s changing but not why it matters, what the risk is, or how much it costs. For complex stacks with dozens of changes, translating a plan into “is this safe to apply right now” is cognitive work that takes time and can miss things. ubx’s AI features close this gap: with UBX_AI_API_KEY set and ai.features = ["plan_summary", "cost_estimate"] in your ubx { } block, ubx plan appends a plain-English summary of what’s changing and why, plus an estimated monthly cost for the resources being created or modified. No separate tool to run, no prompt to write — the context is the plan itself, and the output is directly actionable.

What you’ll learn

  • How to enable plan_summary and cost_estimate AI features
  • What the AI summary and cost estimate look like in practice
  • What ubx validate does without UBX_AI_API_KEY — and what it doesn’t

Why this matters

AI plan summaries aren’t a replacement for reading the plan — they’re a first pass that flags the most significant changes, estimates costs, and surfaces risks you might otherwise miss. They’re especially valuable in PR reviews where the reviewer isn’t the one who wrote the infrastructure change.

The source code

unit "aws_rds_instance" "db" {
  engine                  = "postgres"
  instance_class          = "db.t3.medium"
  identifier              = "myapp-${input.env}-db"
  storage_encrypted       = true
  backup_retention_period = 7
}

unit "aws_s3_bucket_v2" "media" {
  bucket = "myapp-${input.env}-media"
}

unit "aws_lambda_function" "api" {
  name      = "myapp-${input.env}-api"
  runtime   = "nodejs20.x"
  role      = "arn:aws:iam::123456789012:role/lambda-exec"
  s3_bucket = "myapp-artifacts"
  s3_key    = "api/latest.zip"
  handler   = "index.handler"
}

How it works

1

ubx plan produces the resource diff as normal

The standard Pulumi plan runs first — resource adds, changes, and deletes are computed and displayed in the normal ubx plan output format. This doesn’t require AI or an API key.
2

The plan is sent to the AI model

With UBX_AI_API_KEY set, ubx serialises the plan diff and resource configurations and sends them to the configured model. The prompt asks for a plain-English summary of what’s changing and an estimated monthly cost for resources being created or modified.
3

The summary and cost are appended to the plan output

The AI response is streamed and appended below the standard plan output. The summary describes changes in plain language; the cost estimate provides per-resource and total monthly estimates with confidence notes.

Example AI output

This is illustrative static output — your actual summary will reflect your specific plan:
◆ AI Summary

  3 resources will be created:
  • RDS db.t3.medium (myapp-prod-db) — new PostgreSQL database with encryption
    enabled and 7-day backup retention. No existing state — first apply.
  • S3 bucket (myapp-prod-media) — standard media storage bucket.
  • Lambda function (myapp-prod-api) — Node.js 20 API handler.

  No existing resources will be modified or deleted.

  ✦ Risk: Low. All creates, no destructive changes.

◆ Cost Estimate (monthly)

  aws_rds_instance.db     db.t3.medium (us-east-1)   ~$52/month
  aws_s3_bucket_v2.media  S3 standard                ~$1-5/month (usage-based)
  aws_lambda_function.api Lambda (pay-per-request)   ~$0-2/month (usage-based)

  Estimated total: ~$53-59/month
  Confidence: Medium (usage-based resources have variable costs)

Common mistakes

AI features require UBX_AI_API_KEY to be set in the environment. Without it, ubx plan runs normally but skips the summary and cost estimate — no error, just no AI output. If you expect to see a summary and don’t, check that the key is set: echo $UBX_AI_API_KEY.
Set model = "claude-haiku-4-5-20251001" for faster, cheaper plan summaries in CI pipelines where speed matters more than depth. Use "claude-opus-4-8" for interactive plan reviews where you want a more thorough analysis of complex changes.

Run it

ubx validate                        # no AI call — validates syntax only
ubx plan                            # no AI call — no UBX_AI_API_KEY needed
UBX_AI_API_KEY=xxx ubx plan         # plan + AI summary + cost estimate

What you learned

plan_summary and cost_estimate are AI features enabled in the ai { } sub-block
AI features require UBX_AI_API_KEY — without it, plan runs normally with no AI output
The AI summary is appended to the standard plan output — it doesn’t replace it

Next steps

cost_limit constraint

Block apply when estimated cost exceeds a declared limit

ubx block reference

Full ai sub-block syntax and all feature flags