#!/bin/bash # Calculator Email Infrastructure Setup Script set -e echo "🚀 Setting up Calculator Email Infrastructure..." # Check if we're in the right directory if [ ! -f "main.tf" ]; then echo "❌ Error: main.tf not found. Please run this script from infra/email directory" exit 1 fi # Install npm dependencies for Lambda function echo "📦 Installing Lambda dependencies..." if [ ! -d "node_modules" ]; then npm install else echo "✅ Dependencies already installed" fi # Initialize Terraform if needed if [ ! -d ".terraform" ]; then echo "🔧 Initializing Terraform..." terraform init else echo "✅ Terraform already initialized" fi # Plan the infrastructure setup echo "📋 Planning infrastructure setup..." terraform plan # Ask for confirmation echo "" read -p "🤔 Do you want to create this infrastructure? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "🚀 Creating infrastructure..." terraform apply -auto-approve echo "" echo "✅ Infrastructure setup complete!" echo "" echo "📋 Next steps:" echo "1. Go to AWS SES Console and verify the 127local.net domain identity" echo "2. Wait for DKIM verification (should happen automatically)" echo "3. Test by sending an email to calculator@127local.net" echo "" echo "🔍 Useful commands:" echo " terraform output # Show all outputs" echo " terraform output dkim_tokens # Show DKIM tokens" echo " terraform output lambda_function_name # Show Lambda function name" else echo "❌ Infrastructure setup cancelled" exit 1 fi