diff --git a/README.md b/README.md index e368c668..2a5666f1 100644 --- a/README.md +++ b/README.md @@ -37,14 +37,17 @@ This is a one-time setup. The bootstrap script creates the S3 bucket (with a ran ```bash export AWS_PROFILE= export REGION= -./scripts/bootstrap.sh +export ENVIRONMENT=dev # or: prod +./scripts/bootstrap.sh $ENVIRONMENT ``` +> Keep these three variables exported in your shell for the remaining steps. + ### 2. Configure Terraform Variables ```bash -cp terraform/environments/dev.tfvars.example terraform/environments/.tfvars -# Edit dev.tfvars with your desired region, etc. +cp terraform/environments/dev.tfvars.example terraform/environments/$ENVIRONMENT.tfvars +# Edit only if you need to override defaults; region comes from $REGION. ``` ### 3. Deploy Infrastructure @@ -52,7 +55,7 @@ cp terraform/environments/dev.tfvars.example terraform/environments/ +./scripts/deploy-terraform.sh $ENVIRONMENT ``` After deployment, agent workers authenticate with Kiro CLI via device flow. Check the agent pool DynamoDB table or ECS logs for the auth URL and device code. @@ -79,7 +82,7 @@ Create users in the Cognito User Pool. The User Pool ID is available via `terraf ### 6. Deploy Frontend ```bash -./scripts/deploy-frontend.sh +./scripts/deploy-frontend.sh $ENVIRONMENT ``` The application is available at the CloudFront domain: diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 1cdb4dbc..d054255e 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -11,7 +11,7 @@ ENVIRONMENT=${1:-dev} SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_NAME="collaborative-ai-dlc" -REGION="us-east-1" +REGION="${REGION:-us-east-1}" if [[ "$ENVIRONMENT" != "dev" && "$ENVIRONMENT" != "prod" ]]; then echo "Usage: $0 [dev|prod]" diff --git a/scripts/deploy-frontend.sh b/scripts/deploy-frontend.sh index 38a9ea9e..c08d2780 100755 --- a/scripts/deploy-frontend.sh +++ b/scripts/deploy-frontend.sh @@ -30,6 +30,9 @@ fi # Build frontend cd "$SCRIPT_DIR/../frontend" +echo "Installing frontend dependencies..." +npm ci + echo "Building frontend..." npm run build diff --git a/scripts/deploy-terraform.sh b/scripts/deploy-terraform.sh index 7cc52b61..ddbef876 100755 --- a/scripts/deploy-terraform.sh +++ b/scripts/deploy-terraform.sh @@ -12,6 +12,10 @@ fi echo "Deploying environment: $ENVIRONMENT" +# Pass $REGION through to Terraform's aws_region variable so the bootstrap region, +# AWS CLI region, and provider region all stay in sync from a single env var. +export TF_VAR_aws_region="${REGION:-us-east-1}" + echo "Installing root npm dependencies..." (cd "$SCRIPT_DIR/.." && npm ci) diff --git a/scripts/destroy.sh b/scripts/destroy.sh index b527d97d..4a48a0a1 100755 --- a/scripts/destroy.sh +++ b/scripts/destroy.sh @@ -22,6 +22,10 @@ fi cd "$TF_DIR" +# Match deploy-terraform.sh: derive aws_region from $REGION so destroy targets +# the same region the stack was deployed to. +export TF_VAR_aws_region="${REGION:-us-east-1}" + # Ensure we're initialised against the right backend terraform init -reconfigure -backend-config="environments/${ENVIRONMENT}.s3.tfbackend" diff --git a/terraform/environments/dev.tfvars.example b/terraform/environments/dev.tfvars.example index 3b5e6c73..f931098d 100644 --- a/terraform/environments/dev.tfvars.example +++ b/terraform/environments/dev.tfvars.example @@ -1,5 +1,8 @@ environment = "dev" -aws_region = "us-east-1" + +# aws_region is sourced from the REGION env var (via TF_VAR_aws_region in +# deploy-terraform.sh). Uncomment below only to override that. +# aws_region = "us-east-1" # Bedrock model pinning (for claude and opencode drivers) bedrock_model = "us.anthropic.claude-sonnet-4-6"