Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 2.92 KB

File metadata and controls

115 lines (83 loc) · 2.92 KB

Terraform Init - Quick Reference Card

Quick reference for testing Terraform backend initialization. For detailed procedures, see TERRAFORM_INIT_TESTING.md.

Pre-Flight Checklist

# 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.tf

Run Terraform Init

cd agentguard-infrastructure
terraform init

Success Indicators

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.hcl file

State file in S3:

aws s3 ls s3://agentguard-terraform-state-<suffix>/agentguard/

Common Errors & Quick Fixes

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

Validation Commands

# 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

Next Steps After Successful Init

# 1. Configure variables
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values

# 2. Preview changes
terraform plan

# 3. Deploy infrastructure
terraform apply

Required IAM Permissions

S3 Permissions:

  • s3:ListBucket
  • s3:GetObject
  • s3:PutObject

DynamoDB Permissions:

  • dynamodb:PutItem
  • dynamodb:GetItem
  • dynamodb:DeleteItem

Documentation Links

Support

For detailed troubleshooting and testing procedures, refer to TERRAFORM_INIT_TESTING.md.