Top 200 ReposEXPLORER
Browse agents, categories and pages
Back to results
Planned, not doneThe source describes an intention, not a finished result.

Plan and Apply Terraform Changes With Cursor's Agent

Overview

Have Cursor's local agent edit Terraform for a database environment and run terraform plan, then read the plan yourself and approve the apply command only if it matches the change.

Problem or Objective

More in Coding and Code Review

AI Agents and Models

Tools and Integrations

Tools
Cursor · Terraform
Prerequisites
A Terraform repository, Terraform installed where the agent's terminal runs, and cloud credentials scoped to a non-production environment.

How It Works

Open the infrastructure repository in Cursor and work against a non-production environment first. Describe the change, for example a new read replica or a changed database parameter, and the module the agent should touch. Ask the agent to edit the Terraform, run terraform fmt, terraform validate and terraform plan, and summarise every resource the plan would create, change, replace or destroy. Cursor's foreground agent asks for your approval before each terminal command, so approve the format, validate and plan commands and read the plan output yourself. Approve the terraform apply command only when the plan matches what you asked for and nothing is destroyed or replaced unexpectedly; otherwise reject it and ask for a revision. After a successful apply, commit the change and open a pull request so your team can review it. If the apply fails on a missing permission, fix the role through your normal process rather than widening the agent's access.

Implementation Workflow

Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.

  1. Choose the agentSet up Cursor.
  2. Connect the toolsConnect the tools this workflow relies on: Cursor, Terraform.
  3. Check the prerequisitesA Terraform repository, Terraform installed where the agent's terminal runs, and cloud credentials scoped to a non-production environment.
  4. Gather your detailsCollect what the prompt asks for: Terraform module path, The change you want, Environment, Resources that must not change.
  5. Run the starter promptPaste the starter prompt below into Cursor and adapt it to your case.
  6. Check against the documentationCompare what you get with the documentation at cursor.com before you rely on it.

Practical Starter Prompt: Plan a Terraform change for my approval

Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].

Preview
In this repository, change the Terraform in [Terraform module path] to [The change you want] in the [Environment] environment only. Run terraform fmt, terraform validate and terraform plan, then summarise every resource the plan would create, change, replace or destroy, and flag anything that touches [Resources that must not change]. Stop after the plan and wait for my reply. Run terraform apply only if I explicitly approve that plan, and never use -auto-approve.

Run this with Cursor's local agent so every command needs your approval. Read the full plan output before approving the apply command, and stop if anything is destroyed or replaced unexpectedly.

Expected Results and Benefits

This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.

This is a suggested workflow, not a reported outcome. Cursor's documentation says the foreground agent requires user approval for every terminal command, while cloud agents run in isolated VMs with full development environments and auto-run their commands, which Cursor flags as a data-exfiltration risk. The pages do not mention Terraform, so how well the agent writes a given change, and whether your credentials allow plan and apply, is for you to check.

Limitations and Considerations

Use the local foreground agent for this rather than a cloud agent, because cloud agents auto-run terminal commands. Give the terminal credentials scoped to the environment you are changing; for cloud roles Cursor recommends short-lived OIDC tokens over long-lived keys. An apply can delete or replace a database, so read the plan for any destroy or replace action, take a backup or snapshot first, and follow your team's change process. Check Terraform's own documentation for state locking and workspaces. Results depend on your setup and were not independently reproduced by Top 200 Repos.

Sources

  1. Secrets & Network | Cursor Docs (opens in a new tab)

    Project documentation · cursor.com · Undated · Source checked 26 Nov 2026, 17:27 UTC

    What this source supports
    • The cloud agent auto-runs all terminal commands, which differs from the foreground agent, which requires user approval for every command; auto-running introduces data exfiltration risk through prompt injection.
    • For cloud roles and internal APIs, Cursor recommends short-lived OIDC tokens over long-lived keys in Secrets.
  2. Cloud Agents | Cursor Docs (opens in a new tab)

    Project documentation · cursor.com · Undated · Source checked 26 Nov 2026, 17:27 UTC

    What this source supports
    • Cloud agents run in isolated VMs in the cloud with full development environments instead of on your local machine.
Report a problem

More with Cursor

Planned, not done

Prototype a Paper-Trading Strategy With Cursor Agent

Use Cursor's agent to add a rule-based trading strategy to an existing codebase, test it on historical data and simulated orders only, and review every change in a pull request before running anything.

cursor.com
Planned, not done

Plan and Supervise Parallel Engineering Workers Across a Large Repository

Split a large codebase change into small tasks, run several Cursor cloud agents in parallel on separate branches, and review each round of pull requests before planning the next.

cursor.com
Planned, not done

Migrate Dashboard Authentication to NextAuth.js in Staging

Have a Cursor cloud agent move a dashboard's sign-in code to NextAuth.js on a separate branch and test it there, leaving the staging release to your review.

docs.grok.com

View all: Cursor