Prompt

How do I keep dev and prod infrastructure separate in code?

Technology / Cloud Infrastructure1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

A good way to keep dev and prod infrastructure separate in code is to use shared modules/components for the common pieces, and environment-specific stacks/config for anything that differs.

Recommended approach

1) Use a layered structure

Organize code into:

  • Reusable modules: VPC, database, app service, IAM, etc.
  • Environment definitions: dev, staging, prod
  • Shared configuration: tagging, naming, defaults

Example layout:

infra/
  modules/
    vpc/
    app/
    database/
  envs/
    dev/
      main.tf
      variables.tf
      terraform.tfvars
    prod/
      main.tf
      variables.tf
      terraform.tfvars

2) Keep env-specific values in separate files

Do not hardcode environment differences in module code. Put them in:

  • separate variable files
  • separate config files
  • separate parameter sets

Examples of values that usually differ:

  • instance sizes
  • replica counts
  • autoscaling thresholds
  • feature flags
  • logging/monitoring levels
  • DNS names
  • secrets references

3) Use separate state for each environment

This is critical. Dev and prod should not share the same state.

For example:

  • dev state file / backend key
  • prod state file / backend key

That prevents accidental cross-environment changes.

4) Use separate accounts/subscriptions/projects if possible

Best practice is:

  • separate AWS accounts
  • separate GCP projects
  • separate Azure subscriptions

This gives you a real boundary beyond just code.

5) Use workspaces only if they fit your workflow

Terraform workspaces can separate environments, but many teams prefer:

  • separate directories per environment, or
  • separate state files/accounts

Workspaces are fine for simple cases, but they can become confusing for production-grade setups.

6) Parameterize modules

Your modules should accept inputs like:

  • environment
  • instance_type
  • desired_count
  • enable_debug
  • domain_name

Then the environment layer decides the values.

Example:

module "app" {
  source        = "../../modules/app"
  environment   = "dev"
  instance_type  = "t3.small"
  desired_count  = 1
}

and in prod:

module "app" {
  source        = "../../modules/app"
  environment   = "prod"
  instance_type  = "m6i.large"
  desired_count  = 3
}

7) Use validation and policy checks

Add safeguards like:

  • naming conventions
  • required tags
  • policy-as-code
  • approval gates for prod
  • CI checks that prevent applying prod from a dev pipeline

8) Use separate CI/CD pipelines

Have:

  • dev pipeline
  • prod pipeline

Common pattern:

  • dev auto-deploys on merge
  • prod requires manual approval

9) Keep secrets separate

Use separate secret stores or secret namespaces per environment:

  • dev secrets
  • prod secrets

Never reuse prod secrets in dev.

10) Make prod harder to modify

For prod:

  • stricter IAM
  • fewer write permissions
  • manual approvals
  • drift detection
  • more conservative change windows

Rule of thumb

Shared code, separate configuration, separate state, separate permissions.

If you want, I can show you a concrete example for:

  • Terraform
  • Pulumi
  • AWS CDK
  • Kubernetes/Helm

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.