Prompt

How do I run infrastructure plans in pull requests before apply?

Technology / Cloud Infrastructure1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

A common pattern is:

  1. Run plan automatically on every pull request
  2. Post the plan output back to the PR
  3. Only run apply after the PR is approved and merged
    or via a separate manual approval step

Typical workflow

1) On PRs: run plan

Configure your CI/CD pipeline to trigger on pull request events. In that job:

  • check out the code
  • authenticate to your cloud/provider
  • initialize Terraform/OpenTofu
  • run plan
  • save the plan as an artifact or comment it on the PR

Example with Terraform:

terraform init
terraform plan -out=tfplan
terraform show -no-color tfplan

2) On merge to main: apply

Run apply only on the main branch, ideally with protections:

terraform init
terraform apply -auto-approve tfplan

In most teams, apply is either:

  • automatic after merge to main
  • manual with an approval gate
  • restricted to a protected environment

Recommended safeguards

  • Use remote state so the plan reflects current infrastructure
  • Use the same variables in plan and apply
  • Store the plan artifact if you want to apply exactly what was reviewed
  • Limit credentials on PR builds
    • read-only where possible
    • don’t expose secrets to untrusted forked PRs
  • Comment the plan on the PR for visibility
  • Fail the PR if the plan has changes only if that matches your policy

Example GitHub Actions setup

name: terraform

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  plan:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hashicorp/setup-terraform@v3
      - run: terraform init
      - run: terraform plan -no-color -out=tfplan
      - run: terraform show -no-color tfplan

  apply:
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hashicorp/setup-terraform@v3
      - run: terraform init
      - run: terraform apply -auto-approve

Best practice

If you want the exact reviewed plan to be applied, generate the plan in PR validation, store it as an artifact, and then apply that artifact after merge. If not, just rerun plan during apply to ensure it reflects the latest state.

If you tell me which tool you’re using—Terraform, OpenTofu, Pulumi, AWS CDK, etc.—and which CI system—GitHub Actions, GitLab CI, Azure DevOps, Jenkins—I can give you a ready-to-use pipeline example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.