33Write-Host " === AgentCore Demo Deployment ===" - ForegroundColor Cyan
44
55# Step 1: Verify AWS credentials
6- Write-Host " `n [1/10 ] Verifying AWS credentials..." - ForegroundColor Yellow
6+ Write-Host " `n [1/11 ] Verifying AWS credentials..." - ForegroundColor Yellow
77Write-Host " (Checking AWS CLI configuration and validating access)" - ForegroundColor Gray
88
99# Check if AWS credentials are configured
@@ -26,7 +26,7 @@ Write-Host " Authenticated as: $arn" -ForegroundColor Green
2626Write-Host " AWS Account: $accountId " - ForegroundColor Green
2727
2828# Step 2: Check AWS CLI version
29- Write-Host " `n [2/10 ] Checking AWS CLI version..." - ForegroundColor Yellow
29+ Write-Host " `n [2/11 ] Checking AWS CLI version..." - ForegroundColor Yellow
3030$awsVersion = aws -- version 2>&1
3131$versionMatch = $awsVersion -match ' aws-cli/(\d+)\.(\d+)\.(\d+)'
3232if ($versionMatch ) {
@@ -56,7 +56,7 @@ if ($versionMatch) {
5656}
5757
5858# Step 3: Check AgentCore availability in current region
59- Write-Host " `n [3/10 ] Checking AgentCore availability in current region..." - ForegroundColor Yellow
59+ Write-Host " `n [3/11 ] Checking AgentCore availability in current region..." - ForegroundColor Yellow
6060# Detect current region from AWS CLI configuration
6161$currentRegion = aws configure get region
6262if ([string ]::IsNullOrEmpty($currentRegion )) {
@@ -86,8 +86,27 @@ if ($LASTEXITCODE -ne 0) {
8686}
8787Write-Host " ✓ AgentCore is available in $currentRegion " - ForegroundColor Green
8888
89- # Step 4: Install CDK dependencies
90- Write-Host " `n [4/10] Installing CDK dependencies..." - ForegroundColor Yellow
89+ # Step 4: Update Dockerfile with current region
90+ Write-Host " `n [4/11] Updating Dockerfile with current region..." - ForegroundColor Yellow
91+ Write-Host " (Setting AWS_REGION and AWS_DEFAULT_REGION to $currentRegion in agent/Dockerfile)" - ForegroundColor Gray
92+
93+ $dockerfilePath = " agent/Dockerfile"
94+ if (Test-Path $dockerfilePath ) {
95+ $dockerfileContent = Get-Content $dockerfilePath - Raw
96+
97+ # Replace both AWS_REGION and AWS_DEFAULT_REGION with current region
98+ $dockerfileContent = $dockerfileContent -replace ' AWS_REGION=[\w-]+' , " AWS_REGION=$currentRegion "
99+ $dockerfileContent = $dockerfileContent -replace ' AWS_DEFAULT_REGION=[\w-]+' , " AWS_DEFAULT_REGION=$currentRegion "
100+
101+ # Write back to file
102+ Set-Content - Path $dockerfilePath - Value $dockerfileContent - NoNewline
103+ Write-Host " ✓ Updated Dockerfile with region: $currentRegion " - ForegroundColor Green
104+ } else {
105+ Write-Host " ⚠ Dockerfile not found at $dockerfilePath , skipping region update..." - ForegroundColor Yellow
106+ }
107+
108+ # Step 5: Install CDK dependencies
109+ Write-Host " `n [5/11] Installing CDK dependencies..." - ForegroundColor Yellow
91110Write-Host " (Installing AWS CDK libraries and TypeScript packages for infrastructure code)" - ForegroundColor Gray
92111if (-not (Test-Path " cdk/node_modules" )) {
93112 Push-Location cdk
@@ -97,8 +116,8 @@ if (-not (Test-Path "cdk/node_modules")) {
97116 Write-Host " CDK dependencies already installed, skipping..." - ForegroundColor Gray
98117}
99118
100- # Step 5 : Install frontend dependencies
101- Write-Host " `n [5/10 ] Installing frontend dependencies..." - ForegroundColor Yellow
119+ # Step 6 : Install frontend dependencies
120+ Write-Host " `n [6/11 ] Installing frontend dependencies..." - ForegroundColor Yellow
102121Write-Host " (Installing React, Vite, Cognito SDK, and UI component libraries)" - ForegroundColor Gray
103122Push-Location frontend
104123# Commented out to save time during development - uncomment for clean builds
@@ -111,7 +130,7 @@ Pop-Location
111130
112131# Step 6: Create placeholder dist BEFORE any CDK commands
113132# (CDK synthesizes all stacks even when deploying one, so frontend/dist must exist)
114- Write-Host " `n [6/10 ] Creating placeholder frontend build..." - ForegroundColor Yellow
133+ Write-Host " `n [7/11 ] Creating placeholder frontend build..." - ForegroundColor Yellow
115134Write-Host " (Generating temporary HTML file - required for CDK synthesis)" - ForegroundColor Gray
116135if (-not (Test-Path " frontend/dist" )) {
117136 New-Item - ItemType Directory - Path " frontend/dist" - Force | Out-Null
@@ -121,7 +140,7 @@ if (-not (Test-Path "frontend/dist")) {
121140}
122141
123142# Step 7: Bootstrap CDK (if needed)
124- Write-Host " `n [7/10 ] Bootstrapping CDK environment..." - ForegroundColor Yellow
143+ Write-Host " `n [8/11 ] Bootstrapping CDK environment..." - ForegroundColor Yellow
125144Write-Host " (Setting up CDK deployment resources in your AWS account/region)" - ForegroundColor Gray
126145Push-Location cdk
127146$timestamp = Get-Date - Format " yyyyMMddHHmmss"
@@ -134,7 +153,7 @@ if ($LASTEXITCODE -ne 0) {
134153}
135154
136155# Step 8: Deploy infrastructure stack
137- Write-Host " `n [8/10 ] Deploying infrastructure stack..." - ForegroundColor Yellow
156+ Write-Host " `n [9/11 ] Deploying infrastructure stack..." - ForegroundColor Yellow
138157Write-Host " (Creating ECR repository, CodeBuild project, S3 bucket, and IAM roles)" - ForegroundColor Gray
139158Push-Location cdk
140159$timestamp = Get-Date - Format " yyyyMMddHHmmss"
@@ -147,7 +166,7 @@ if ($LASTEXITCODE -ne 0) {
147166}
148167
149168# Step 9: Deploy auth stack
150- Write-Host " `n [9/10 ] Deploying authentication stack..." - ForegroundColor Yellow
169+ Write-Host " `n [10/11 ] Deploying authentication stack..." - ForegroundColor Yellow
151170Write-Host " (Creating Cognito User Pool with email verification and password policies)" - ForegroundColor Gray
152171Push-Location cdk
153172$timestamp = Get-Date - Format " yyyyMMddHHmmss"
@@ -160,7 +179,7 @@ if ($LASTEXITCODE -ne 0) {
160179}
161180
162181# Step 10: Deploy backend stack (triggers build and waits via Lambda)
163- Write-Host " `n [10/10 ] Deploying AgentCore backend stack..." - ForegroundColor Yellow
182+ Write-Host " `n [11/11 ] Deploying AgentCore backend stack..." - ForegroundColor Yellow
164183Write-Host " (Uploading agent code, building ARM64 Docker image, creating AgentCore runtime with built-in Cognito auth)" - ForegroundColor Gray
165184Write-Host " Note: CodeBuild will compile the container image - this takes 5-10 minutes" - ForegroundColor DarkGray
166185Write-Host " The deployment will pause while waiting for the build to complete..." - ForegroundColor DarkGray
0 commit comments