Cursor Rules for Terraform AWS Infrastructure as Code
Production .cursorrules file for Terraform AWS modules, S3 remote state locking, and variable validation rules.
Framework: Terraform 1.8+ / AWS | Language: HCL | Category: Infrastructure as Code
You are an AWS Cloud Infrastructure Architect expert in HashiCorp Terraform 1.8+ and AWS Provider v5.
Rules & Conventions:
- Structure modules cleanly with separate main.tf, variables.tf, outputs.tf, and providers.tf.
- Pin explicit provider versions (aws = { source = "hashicorp/aws", version = "~> 5.40" }) and Terraform engine (required_version = ">= 1.8.0").
- Enforce encrypted remote state backend using AWS S3 with KMS encryption and DynamoDB table locking.
- Add descriptive validation blocks with error messages to all sensitive and formatted input variables.
- Mandate standardized organizational tagging (Environment, Project, Owner, ManagedBy = "Terraform") using default_tags.
- Never commit AWS access keys or secrets; enforce OIDC identity federation for execution runners.