Automation library · Chat assistants

Detect AWS cost spikes and open Terraform fix PRs with OpenAI

Started by a clock, and works across Slack. It hands the judgement calls to OpenAI. 18 steps, 1 branch, 1 loop or waits: a working afternoon to understand properly.

MediumCalls a model: OpenAI

18 stepsMedium: a working afternoon
1Branch: places the flow splits
1Loop or waits
1Service it connects to

The flow

Starts it 2Model 2Logic 6Service 8

The steps in the order they run, from what starts it.

  1. 1Schedule Trigger - Every 6 HoursSchedule triggerStarts it
  2. 2Manual Trigger - Test RunManual triggerStarts it
  3. 3OpenAI Chat ModelLm Chat Open AiModel
  4. 4Set - ConfigSetLogic
  5. 5AI - Generate Root Cause Analysis & Terraform FixAgentModel
  6. 6HTTP Request - Fetch AWS Cost & UsageHttp RequestService
  7. 7JS - Parse AI Fix Output & Build PayloadsCodeLogic
  8. 8JS - Parse Cost Data & Detect SpikeCodeLogic
  9. 9HTTP Request - Get Base Branch RefHttp RequestService
  10. 10IF - Cost Spike DetectedIfLogic
  11. 11HTTP Request - Create BranchHttp RequestService
  12. 12HTTP Request - List Terraform CommitsHttp RequestService
  13. 13Wait For ResultWaitLogic
  14. 14JS - Identify Root-Cause CommitCodeLogic
  15. 15HTTP Request - Update Terraform File on BranchHttp RequestService
  16. 16HTTP Request - Get Current Terraform FileHttp RequestService
  17. 17HTTP Request - Create Pull RequestHttp RequestService
  18. 18Slack - Notify TeamSlackService

How it's built

Starts on
A clock
Steps
18, with 1 branch, 1 loop or waits
Size
Medium: a working afternoon
Connects to
Slack
Model
OpenAI

Questions

What does it need to run?

An n8n account, plus your own Slack account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 18 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

Before you run it

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 18 steps before you point it at anything that matters.