# Review Terraform pull requests with GitHub and OpenAI: n8n workflow

> Started by an event in a connected app, and works across GitHub, Postgres and Slack. It puts OpenAI behind a retrieval step, so answers are drawn from...

Source: https://millionrounds.com/workflow/review-terraform-pull-requests-with-github-and-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Content](https://millionrounds.com/workflows?category=Content#library)

# Review Terraform pull requests with GitHub and OpenAI

Started by an event in a connected app, and works across GitHub, Postgres and Slack. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 20 steps, 2 branches, 1 loop or waits: a working afternoon to understand properly.

Medium Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Freview-terraform-pull-requests-with-github-and-openai)

**20 steps** Medium: a working afternoon

**2** Branches: places the flow splits

**1** Loop or waits

**3** Services it connects to

## The flow

Starts it 1 Model 7 Logic 5 Service 7

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

- 1 **GitHub Trigger - PR Opened/Updated** Github trigger *Starts it*
- 2 **Tool - Run Terraform Plan** Tool Http Request *Model*
- 3 **Tool - Run Security Scan** Tool Http Request *Model*
- 4 **Tool - Estimate Cost Impact** Tool Http Request *Model*
- 5 **Tool - RAG Search IaC Standards** Tool Vector Store *Model*
- 6 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 7 **Window Buffer Memory** Memory Buffer Window *Model*
- 8 **Set - Config** Set *Logic*
- 9 **AI Agent - Terraform Reviewer** Agent *Model*
- 10 **Get - PR Diff** Github *Service*
- 11 **Set - Parse Agent Output** Set *Logic*
- 12 **Postgres - Log PR Review** Postgres *Service*
- 13 **GitHub - Post Review Comment** Github *Service*
- 14 **IF - Review Passed** If *Logic*
- 15 **GitHub - Approve PR (auto)** Github *Service*
- 16 **Slack - Request Security Review** Slack *Service*
- 17 **Wait - For Security Sign-Off** Wait *Logic*
- 18 **IF - Security Approved** If *Logic*
- 19 **GitHub - Approve PR (delayed)** Github *Service*
- 20 **GitHub - Request Changes** Github *Service*

## How it's built

- **Starts on:** An event in a connected app
- **Steps:** 20, with 2 branches, 1 loop or waits
- **Size:** Medium: a working afternoon
- **Connects to:** GitHub, Postgres, Slack
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

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

What starts it?

It starts on an event in a connected app.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 20 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 20 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Freview-terraform-pull-requests-with-github-and-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[GitHub](https://millionrounds.com/workflows?service=GitHub#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Slack](https://millionrounds.com/workflows?service=Slack#library)

## Workflows like it

Also content, with the same services where possible, closest in size first.

- [**Convert audio emails to Japanese transcripts with OpenAI** 20 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/convert-audio-emails-to-japanese-transcripts-with-openai)
- [**Create & publish Instagram carousels with Nano Banana Pro** 20 steps · calls a model · Slack](https://millionrounds.com/workflow/create-and-publish-instagram-carousels-with-nano-banana-pro)
- [**Promote your YouTube video on X with OpenAI and Discord** 20 steps · calls a model · Discord, Gmail](https://millionrounds.com/workflow/promote-your-youtube-video-on-x-with-openai-and-discord)
- [**Query Google Sheets/CSV data with PostgreSQL** 20 steps · calls a model · Google Sheets, Postgres](https://millionrounds.com/workflow/query-google-sheets-csv-data-with-postgresql)
- [**Route AI tasks between Anthropic Claude models with Postgres** 20 steps · calls a model · Postgres](https://millionrounds.com/workflow/route-ai-tasks-between-anthropic-claude-models-with-postgres)
- [**Transcribe LinkedIn Ad Library video ads to Google Sheets** 20 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/transcribe-linkedin-ad-library-video-ads-to-google-sheets)
