Generate Terraform backend configurations for remote state with locking, encryption, and multi-environment setup.
Act as a Terraform infrastructure expert. Generate backend configuration for remote state management with proper security. ## Input Parameters - **Cloud Provider**: [PROVIDER] (AWS S3 / Azure Blob / GCP GCS) - **Environment Count**: [ENV_COUNT] (dev, staging, prod) - **State Locking**: [LOCK_METHOD] (DynamoDB / Cosmos DB / GCS native) - **Encryption**: [ENCRYPTION] (SSE-S3 / SSE-KMS / CMEK) - **Team Size**: [TEAM_SIZE] ## Generate 1. **Backend configuration** (`backend.tf`) for each environment. 2. **State bucket/container creation** script (Terraform or CLI): - Versioning enabled for state history - Encryption at rest - Access logging enabled - Lifecycle rules for old versions - Bucket policy denying unencrypted uploads 3. **Lock table** creation for state locking. 4. **Workspace strategy** or directory-based environment separation with pros/cons. 5. **Partial configuration** files for each environment (`backend-dev.hcl`, etc.). 6. **State migration** commands for moving from local to remote. 7. **CI/CD integration** snippet for `terraform init -backend-config=...`. ## Security - Require MFA for state bucket access. - Cross-account access for shared infrastructure state. - State file should never be in version control. - Include `.gitignore` entries for state files. ## Output Format Return all configuration files with directory structure. Include a decision matrix for workspace vs directory approach and a troubleshooting guide for common state issues.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4.
Select your cloud provider, number of environments, and locking mechanism. The prompt generates all backend configuration files and setup scripts.
Initial release
Sign in and download this prompt to leave a review.