Skip to main content

AWS Backend Setup

Configure S3 bucket and DynamoDB table for Terraform remote state management with encryption, versioning, and state locking.

Overview

Terraform backend stores infrastructure state in S3 with DynamoDB for state locking, preventing concurrent modifications.

Benefits

  • Team collaboration: Shared state across team members
  • State locking: Prevents concurrent modifications
  • Version history: S3 versioning for rollback capability
  • Encryption: KMS encryption for sensitive data
  • Audit trail: Access logging for compliance

Architecture

Quick Setup

1

Navigate to backend setup

2

Create terraform.tfvars

3

Initialize and deploy

Creates:
  • S3 bucket: mcp-langgraph-terraform-state-prod
  • DynamoDB table: mcp-langgraph-terraform-lock-prod
  • KMS key for encryption
  • S3 bucket for access logs
4

Note the outputs

Save these values for backend configuration:
  • state_bucket_name
  • lock_table_name

Backend Configuration

For Environment Deployments

Initialize Backend

Features

S3 State Bucket

Enabled for rollback capability

DynamoDB Lock Table

Prevents concurrent Terraform runs

Multiple Environments

Separate State Per Environment

Same Bucket, Different Keys

Security Best Practices

Restrict access to authorized users only
Minimal permissions for state locking
Require MFA to delete state versions

Disaster Recovery

State Backup

1

Manual backup

2

Cross-region replication

State Recovery

1

List versions

2

Restore specific version

3

Verify state

Troubleshooting

Cause: S3 bucket doesn’t exist or no accessSolution:
Cause: Previous Terraform run didn’t release lock (e.g., Ctrl+C during apply)Solution:
Cause: Backend not created yetSolution:

Cost

Terraform AWS

AWS infrastructure modules

EKS Production

Production deployment guide

GCP Backend

GCP backend setup (GCS + Cloud Storage)