Quick reference for testing Terraform backend initialization. For detailed procedures, see TERRAFORM_INIT_TESTING.md.
# 1. Verify AWS credentials
aws sts get-caller-identity
# 2. Verify S3 bucket exists
aws s3api head-bucket --bucket agentguard-terraform-state-<suffix>
# 3. Verify DynamoDB table exists
aws dynamodb describe-table --table-name agentguard-terraform-state-lock --region us-east-1
# 4. Verify backend.tf configuration
cat backend.tfcd agentguard-infrastructure
terraform init✓ Backend initialization message:
Successfully configured the backend "s3"!
✓ Provider installation:
- Installing hashicorp/aws v5.31.0...
- Installed hashicorp/aws v5.31.0 (signed by HashiCorp)
✓ Files created:
.terraform/directory.terraform.lock.hclfile
✓ State file in S3:
aws s3 ls s3://agentguard-terraform-state-<suffix>/agentguard/| Error | Quick Fix |
|---|---|
| Bucket not found | Run ./setup-backend.sh or verify bucket name in backend.tf |
| Access denied | Check IAM permissions for S3 and DynamoDB |
| DynamoDB table not found | Run ./setup-backend.sh or verify table name |
| Region mismatch | Update region in backend.tf to match bucket region |
| Provider version conflict | Run terraform init -upgrade |
| Terraform version too old | Upgrade to Terraform >= 1.5.0 |
# Verify Terraform version
terraform version
# Verify backend state
aws s3 ls s3://agentguard-terraform-state-<suffix>/agentguard/
# Verify DynamoDB table schema
aws dynamodb describe-table --table-name agentguard-terraform-state-lock --query 'Table.KeySchema'
# Validate Terraform configuration
terraform validate
# Check formatting
terraform fmt -check# 1. Configure variables
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values
# 2. Preview changes
terraform plan
# 3. Deploy infrastructure
terraform applyS3 Permissions:
s3:ListBuckets3:GetObjects3:PutObject
DynamoDB Permissions:
dynamodb:PutItemdynamodb:GetItemdynamodb:DeleteItem
- Detailed Testing Guide: TERRAFORM_INIT_TESTING.md
- Setup Guide: SETUP.md
- Backend Setup: BACKEND_SETUP_README.md
- Manual Setup: MANUAL_SETUP_INSTRUCTIONS.md
For detailed troubleshooting and testing procedures, refer to TERRAFORM_INIT_TESTING.md.