Review Terraform pull requests with GitHub, GPT-4.1, Postgres and Slack
Needs changesNeeds changes. This template uses 2 thing(s) that n8n 3.0 removes: HTTP Request Tool (legacy), AI Agent v1 (old agent modes). 2 breaking item(s) found. Static check, last run 2026-10-19.
What to replace before upgrading
| Removed in 3.0 | Replace with |
|---|---|
| HTTP Request Tool (legacy) Tool - Run Terraform Plan, Tool - Run Security Scan, Tool - Estimate Cost Impact | HTTP Request node connected to the AI Agent's Tool input |
| AI Agent v1 (old agent modes) AI Agent - Terraform Reviewer (v1.6) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (12)
- Github Trigger
n8n-nodes-base.githubTrigger - Edit Fields (Set)
n8n-nodes-base.set - GitHub
n8n-nodes-base.github - HTTP Request Tool
@n8n/n8n-nodes-langchain.toolHttpRequest - Vector Store Question Answer Tool
@n8n/n8n-nodes-langchain.toolVectorStore - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - AI Agent
@n8n/n8n-nodes-langchain.agent - Postgres
n8n-nodes-base.postgres - If
n8n-nodes-base.if - Slack
n8n-nodes-base.slack - Wait
n8n-nodes-base.wait
What it does
Quick overview This workflow reviews Terraform pull requests in GitHub using an OpenAI tool-calling agent that can run plan, security, cost, and standards checks, then logs results to Postgres, comments on the PR, and auto-approves clean changes or routes flagged ones to Slack for human sign-off. How it works 1. Triggers on GitHub pull request events for the selected repository. 2. Extracts PR metadata (repo, branch, author, title, and PR number) and fetches the PR details from GitHub for review context. 3. Uses an OpenAI agent with session memory to review the PR and, as needed, calls HTTP tools to run a Terraform plan, run a Terraform security scan, estimate cost impact, and query a vector store of internal IaC standards. 4. Parses the agent’s structured JSON output into fields such as findings, overall risk, verdict, blocking issues, and cost impact summary. 5. Inserts the review record into a Postgres terraformprreviews table and posts a formatted review comment back to the GitHub PR. 6. If the verdict is pass, submits a GitHub PR approval; otherwise, sends the findings to a Slack channel, waits for a human security decision, and then either approves the PR or requests changes in GitHub. Setup 1. Connect GitHub credentials with permission to read pull requests and create comments/reviews, and select the target owner and repository in the GitHub trigger and GitHub nodes. 2. Add OpenAI credentials for the Chat Model and configure the model selection (for example, gpt-4.1). 3. Configure the HTTP endpoints used by the Terraform plan, security scan, and cost estimate tools (for example, CI/internal APIs) so they return usable results for the agent. 4. Set up a vector store for your internal IaC standards and connect the vector store credentials used by the RAG search tool. 5. Add Postgres credentials and create a terraformprreviews table with columns matching the insert (prnumber, repo, author, findings, overallrisk, verdict, blockingissues, costimpactsummary, createdat). 6. Add Slack credentials, set the target channel (for example, terraform-security-review), and configure how reviewers resume the workflow by calling the Wait node’s webhook with a securityApproved value.