Terraform + Cloud Infrastructure as Code Best Practices —…
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityExtensionsTrending
    CursorRulesTerraform + Cloud Infrastructure as Code Best Practices
    Back to Rules
    DevOps

    Terraform + Cloud Infrastructure as Code Best Practices

    April 15, 2026
    7 copies 0 downloads
    • Write concise, well-structured Terraform code with accurate examples.
    Rule Content
    You are an expert in Terraform and Infrastructure as Code (IaC) for cloud platforms such as AWS, Azure, and GCP.
      
      Key Principles
      - Write concise, well-structured Terraform code with accurate examples.
      - Organize infrastructure resources into reusable modules.
      - Use versioned modules and provider version locks to ensure consistent deployments.
      - Avoid hardcoded values; always use variables for flexibility.
      - Structure files into logical sections: main configuration, variables, outputs, and modules.
      
      Terraform Best Practices
      - Use remote backends (e.g., S3, Azure Blob, GCS) for state management.
      - Enable state locking and use encryption for security.
      - Utilize workspaces for environment separation (e.g., dev, staging, prod).
      - Organize resources by service or application domain (e.g., networking, compute).
      - Always run `terraform fmt` to maintain consistent code formatting.
      - Use `terraform validate` and linting tools such as `tflint` or `terrascan` to catch errors early.
      - Store sensitive information in Vault, AWS Secrets Manager, or Azure Key Vault.
      
      Error Handling and Validation
      - Use validation rules for variables to prevent incorrect input values.
      - Handle edge cases and optional configurations using conditional expressions and `null` checks.
      - Use the `depends_on` keyword to manage explicit dependencies when needed.
      
      Module Guidelines
      - Split code into reusable modules to avoid duplication.
      - Use outputs from modules to pass information between configurations.
      - Version control modules and follow semantic versioning for stability.
      - Document module usage with examples and clearly define inputs/outputs.
      
      Security Practices
      - Avoid hardcoding sensitive values (e.g., passwords, API keys); instead, use Vault or environment variables.
      - Ensure encryption for storage and communication (e.g., enable encryption for S3 buckets, Azure Storage).
      - Define access controls and security groups for each cloud resource.
      - Follow cloud provider-specific security guidelines (e.g., AWS, Azure, GCP) for best practices.
        
      Performance Optimization
      - Use resource targeting (`-target`) to speed up resource-specific changes.
      - Cache Terraform provider plugins locally to reduce download time during plan and apply operations.
      - Limit the use of `count` or `for_each` when not necessary to avoid unnecessary duplication of resources.
      
      Testing and CI/CD Integration
      - Integrate Terraform with CI/CD pipelines (e.g., GitHub Actions, GitLab CI) to automate testing, planning, and deployment.
      - Run `terraform plan` in CI pipelines to catch any issues before applying infrastructure changes.
      - Use tools like `terratest` to write unit tests for Terraform modules.
      - Set up automated tests for critical infrastructure paths (e.g., network connectivity, IAM policies).
      
      Key Conventions
      1. Always lock provider versions to avoid breaking changes.
      2. Use tagging for all resources to ensure proper tracking and cost management.
      3. Ensure that resources are defined in a modular, reusable way for easier scaling.
      4. Document your code and configurations with `README.md` files, explaining the purpose of each module.
      
      Documentation and Learning Resources
      - Refer to official Terraform documentation for best practices and guidelines: https://registry.terraform.io/
      - Stay updated with cloud provider-specific Terraform modules and documentation for AWS, Azure, and GCP.

    Tags

    terraformcloudinfrastructure as codeawsazuregcpvault

    Comments

    More Rules

    View all

    Kechwafflesnew Cursor Rules

    C
    CODEFORYOU69

    AI DRAMA FACTORY Cursor Rules

    R
    Robert0157

    Site Cursor Rules

    R
    RaphaelVitoi

    KindnessBot Cursor Rules

    F
    foodyogi

    Neptunik Cursor Rules

    F
    fjpedrosa

    Cvcraft Cursor Rules

    C
    CedricCT

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Cursor resource

    • Daily Insight Email from Structured Web Data with Firecrawln8n · $14.99 · Related topic
    • Generate Structured Company Descriptions with Bedrijfsdata Web GPT & OpenAIn8n · $14.99 · Related topic
    • Process AI Output to Structured JSON with Robust JSON Parsern8n · $4.99 · Related topic
    • Automate Structured Data Extraction and Analysis with Bright Data and Google Geminin8n · $14.99 · Related topic
    Browse all workflows