From 730b50faad615efff6db4485662edade7199974a Mon Sep 17 00:00:00 2001 From: Carmelo Daniele <32391685+c-daniele@users.noreply.github.com> Date: Sat, 7 Feb 2026 22:14:14 +0100 Subject: [PATCH] feat: remove hard-coded values and use environment variables for project name --- agent-blueprint/.env.example | 2 ++ .../infrastructure/bin/app.ts | 2 +- .../infrastructure/scripts/deploy.sh | 5 ++-- agent-blueprint/deploy.sh | 28 ++++++++++--------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/agent-blueprint/.env.example b/agent-blueprint/.env.example index ef120ffc..a69cfb83 100644 --- a/agent-blueprint/.env.example +++ b/agent-blueprint/.env.example @@ -18,6 +18,8 @@ NEXT_PUBLIC_AWS_REGION=us-west-2 # If false, the app will be publicly accessible without authentication ENABLE_COGNITO=true +PROJECT_NAME=strands-agent-chatbot + # AWS Cognito settings (set automatically during deployment) COGNITO_USER_POOL_ID=us-west-2_XXXXXXXXX COGNITO_USER_POOL_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/agent-blueprint/chatbot-deployment/infrastructure/bin/app.ts b/agent-blueprint/chatbot-deployment/infrastructure/bin/app.ts index 33e809f7..851f2526 100644 --- a/agent-blueprint/chatbot-deployment/infrastructure/bin/app.ts +++ b/agent-blueprint/chatbot-deployment/infrastructure/bin/app.ts @@ -52,7 +52,7 @@ if (enableCognito) { const chatbotStack = new ChatbotStack(app, 'ChatbotStack', { env, ...cognitoProps, - projectName: 'strands-agent-chatbot', + projectName: process.env.PROJECT_NAME || 'strands-agent-chatbot', environment: 'dev', }); diff --git a/agent-blueprint/chatbot-deployment/infrastructure/scripts/deploy.sh b/agent-blueprint/chatbot-deployment/infrastructure/scripts/deploy.sh index 26a0531d..d6a92575 100755 --- a/agent-blueprint/chatbot-deployment/infrastructure/scripts/deploy.sh +++ b/agent-blueprint/chatbot-deployment/infrastructure/scripts/deploy.sh @@ -18,6 +18,7 @@ if [ -f "$ENV_FILE" ]; then echo " - ENABLE_COGNITO: ${ENABLE_COGNITO:-true}" echo " - CORS_ORIGINS: ${CORS_ORIGINS:-not set}" echo " - ALLOWED_IP_RANGES: ${ALLOWED_IP_RANGES:-not set}" + echo " - PROJECT_NAME: ${PROJECT_NAME}" else echo "No .env file found at $ENV_FILE, using environment defaults" fi @@ -46,8 +47,8 @@ echo "Deploying to AWS Account: $ACCOUNT_ID in region: $AWS_REGION" # Check if DynamoDB tables already exist echo "🔍 Checking for existing DynamoDB tables..." -USERS_TABLE_EXISTS=$(aws dynamodb describe-table --table-name strands-agent-chatbot-users --region $AWS_REGION 2>/dev/null && echo "true" || echo "false") -SESSIONS_TABLE_EXISTS=$(aws dynamodb describe-table --table-name strands-agent-chatbot-sessions --region $AWS_REGION 2>/dev/null && echo "true" || echo "false") +USERS_TABLE_EXISTS=$(aws dynamodb describe-table --table-name "${PROJECT_NAME}-users" --region $AWS_REGION 2>/dev/null && echo "true" || echo "false") +SESSIONS_TABLE_EXISTS=$(aws dynamodb describe-table --table-name "${PROJECT_NAME}-sessions" --region $AWS_REGION 2>/dev/null && echo "true" || echo "false") if [ "$USERS_TABLE_EXISTS" = "true" ] && [ "$SESSIONS_TABLE_EXISTS" = "true" ]; then echo "✅ Existing DynamoDB tables found - will import them" diff --git a/agent-blueprint/deploy.sh b/agent-blueprint/deploy.sh index 5fe146c3..3d02a9b7 100755 --- a/agent-blueprint/deploy.sh +++ b/agent-blueprint/deploy.sh @@ -4,6 +4,11 @@ set -e # Strands Agent Chatbot - Main Deployment Orchestrator # Routes to specific deployment scripts +# AWS Profile support +# Usage: PROFILE=myprofile ./deploy.sh + +export PROJECT_NAME="strands-agent-chatbot" + # Colors RED='\033[0;31m' GREEN='\033[0;32m' @@ -165,7 +170,7 @@ deploy_agentcore_runtime() { echo "" NOVA_SECRET_EXISTS=$(aws secretsmanager describe-secret \ - --secret-id "strands-agent-chatbot/nova-act-api-key" \ + --secret-id "${PROJECT_NAME}/nova-act-api-key" \ --query 'Name' \ --output text \ --region "$AWS_REGION" 2>/dev/null || echo "") @@ -181,12 +186,12 @@ deploy_agentcore_runtime() { if [ -n "$NOVA_ACT_KEY" ]; then log_step "Setting Nova Act API Key in Secrets Manager..." aws secretsmanager create-secret \ - --name "strands-agent-chatbot/nova-act-api-key" \ + --name "${PROJECT_NAME}/nova-act-api-key" \ --secret-string "$NOVA_ACT_KEY" \ --description "Nova Act API Key for browser automation" \ --region "$AWS_REGION" > /dev/null 2>&1 || \ aws secretsmanager put-secret-value \ - --secret-id "strands-agent-chatbot/nova-act-api-key" \ + --secret-id "${PROJECT_NAME}/nova-act-api-key" \ --secret-string "$NOVA_ACT_KEY" \ --region "$AWS_REGION" > /dev/null 2>&1 log_info "Nova Act API Key configured" @@ -211,7 +216,7 @@ deploy_agentcore_runtime() { npm run build # Check if ECR repository already exists - if aws ecr describe-repositories --repository-names strands-agent-chatbot-agent-core --region $AWS_REGION &> /dev/null; then + if aws ecr describe-repositories --repository-names "${PROJECT_NAME}-agent-core" --region $AWS_REGION &> /dev/null; then log_info "ECR repository already exists, importing..." export USE_EXISTING_ECR=true else @@ -325,7 +330,6 @@ deploy_mcp_servers() { # Export AWS region for the deployment script export AWS_REGION - export PROJECT_NAME="strands-agent-chatbot" export ENVIRONMENT="dev" # Run deployment @@ -337,7 +341,7 @@ deploy_mcp_servers() { log_step "Verifying deployment..." GATEWAY_URL=$(aws ssm get-parameter \ - --name "/strands-agent-chatbot/dev/mcp/gateway-url" \ + --name "/${PROJECT_NAME}/dev/mcp/gateway-url" \ --query 'Parameter.Value' \ --output text \ --region $AWS_REGION 2>/dev/null || echo "") @@ -446,7 +450,6 @@ deploy_research_agent() { # Export environment variables for the deployment script export AWS_REGION - export PROJECT_NAME="strands-agent-chatbot" export ENVIRONMENT="dev" # Run deployment @@ -480,11 +483,10 @@ deploy_browser_use_agent() { # Export environment variables for the deployment script export AWS_REGION - export PROJECT_NAME="strands-agent-chatbot" export ENVIRONMENT="dev" # Check if ECR repository already exists - if aws ecr describe-repositories --repository-names strands-agent-chatbot-browser-use-agent --region $AWS_REGION &> /dev/null; then + if aws ecr describe-repositories --repository-names "${PROJECT_NAME}-browser-use-agent" --region $AWS_REGION &> /dev/null; then log_info "ECR repository already exists, importing..." export USE_EXISTING_ECR=true else @@ -500,7 +502,7 @@ deploy_browser_use_agent() { log_step "Verifying deployment..." RUNTIME_ARN=$(aws ssm get-parameter \ - --name "/strands-agent-chatbot/dev/a2a/browser-use-agent-runtime-arn" \ + --name "/${PROJECT_NAME}/dev/a2a/browser-use-agent-runtime-arn" \ --query 'Parameter.Value' \ --output text \ --region $AWS_REGION 2>/dev/null || echo "") @@ -617,20 +619,20 @@ display_deployment_summary() { # Get Gateway URL GATEWAY_URL=$(aws ssm get-parameter \ - --name "/strands-agent-chatbot/dev/mcp/gateway-url" \ + --name "/${PROJECT_NAME}/dev/mcp/gateway-url" \ --query 'Parameter.Value' \ --output text \ --region $AWS_REGION 2>/dev/null || echo "Not available") # Get A2A Runtime ARNs RESEARCH_AGENT_ARN=$(aws ssm get-parameter \ - --name "/strands-agent-chatbot/dev/a2a/research-agent-runtime-arn" \ + --name "/${PROJECT_NAME}/dev/a2a/research-agent-runtime-arn" \ --query 'Parameter.Value' \ --output text \ --region $AWS_REGION 2>/dev/null || echo "Not deployed") BROWSER_AGENT_ARN=$(aws ssm get-parameter \ - --name "/strands-agent-chatbot/dev/a2a/browser-use-agent-runtime-arn" \ + --name "/${PROJECT_NAME}/dev/a2a/browser-use-agent-runtime-arn" \ --query 'Parameter.Value' \ --output text \ --region $AWS_REGION 2>/dev/null || echo "Not deployed")