22
33echo " Let's set up your resources"
44sleep 1
5+ rm -rf env_vars.sh
56
67# Read AWS credentials
78read -p " Enter your AWS Access Key ID: " AWS_ACCESS_KEY_ID
@@ -11,7 +12,7 @@ echo # For newline after entering secret key
1112echo " Warning: You need to give proper permission to this IAM user."
1213
1314# Export AWS credentials as environment variables
14- export AWS_ACCESS_KEY_ID=" $AWS_ACCESS_KEY_ID "
15+ export AWS_ACCESS_KEY_ID=" $AWS_ACCESS_KEY_ID "
1516export AWS_SECRET_ACCESS_KEY=" $AWS_SECRET_ACCESS_KEY "
1617
1718# Ask for the AWS region
@@ -20,7 +21,7 @@ read -p "In which AWS region do you want to setup resources? (e.g., us-east-1):
2021# Change directories and update region in Pulumi configurations
2122cd pulumi
2223
23- for dir in setup-s3-temp setup-s3-permanent setup-lambda setup-ecr setup-ecs-task-definition setup-ecs-cluster; do
24+ for dir in setup-s3-temp setup-s3-permanent setup-lambda setup-ecr setup-ecs-task-definition setup-ecs-cluster setup-ec2 ; do
2425 cd $dir
2526 pulumi config set aws:region " $AWS_REGION "
2627 cd ..
@@ -50,6 +51,15 @@ pulumi refresh --yes # Sync the state before deploying
5051pulumi up --yes
5152cd ..
5253
54+ # Ask for the key pair name for EC2 instance
55+ read -p " Enter the name of the EC2 key pair: " KEY_PAIR_NAME
56+ export KEY_PAIR_NAME=" $KEY_PAIR_NAME "
57+
58+ cd setup-ec2
59+ pulumi refresh --yes # Sync the state before deploying
60+ pulumi up --yes
61+ cd ..
62+
5363# Ask for and validate ECR repository name
5464while true ; do
5565 read -p " Enter a valid name for the ECR repository (lowercase, use - or _ if needed): " ECR_REPOSITORY_NAME
@@ -103,7 +113,7 @@ cd ..
103113cd setup-ecs-cluster
104114pulumi refresh --yes # Sync the state before deploying
105115pulumi up --yes
106- cd ..
116+ cd ../..
107117
108118# Save the environment variables to a file
109119echo " Saving environment variables to env_vars.sh..."
@@ -116,6 +126,7 @@ echo "Saving environment variables to env_vars.sh..."
116126 echo " export PERMANENT_BUCKET_NAME=\" ${PERMANENT_BUCKET_NAME:- my-permanent-bucket} \" "
117127 echo " export ECR_REPOSITORY_NAME=\" ${ECR_REPOSITORY_NAME:- my-ecr-repo} \" "
118128 echo " export IMAGE_URI=\" ${IMAGE_URI:- your-image-uri} \" "
129+ echo " export KEY_PAIR_NAME=\" ${KEY_PAIR_NAME:- your-} \" "
119130} > env_vars.sh || { echo " Failed to write to env_vars.sh" ; }
120131
121132# Source the env_vars.shs
0 commit comments