From 610c82cd661651cae1e55ca674e8db16fe50c9a4 Mon Sep 17 00:00:00 2001 From: JustFiesta Date: Wed, 15 May 2024 15:28:10 +0200 Subject: [PATCH] Small fixups --- prepare_aws_enviroment.sh | 3 +++ run_container_on_EC2.sh | 4 ++-- send_image_to_aws.sh | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/prepare_aws_enviroment.sh b/prepare_aws_enviroment.sh index 63caf6791..8c400d3b8 100644 --- a/prepare_aws_enviroment.sh +++ b/prepare_aws_enviroment.sh @@ -107,7 +107,10 @@ echo "EC2 instance is now correctly configured." # Allocate and associate public IP address with EC2 instance echo "Allocating and associating public IP address with EC2 instance..." + PUBLIC_IP=$(aws ec2 allocate-address --domain vpc --region "$REGION" --output text) +export PUBLIC_IP + aws ec2 associate-address --instance-id "$INSTANCE_ID" --public-ip "$PUBLIC_IP" --region "$REGION" echo "Public IP address has been allocated and associated with EC2 instance: $PUBLIC_IP" diff --git a/run_container_on_EC2.sh b/run_container_on_EC2.sh index 8139c958d..2660f5578 100644 --- a/run_container_on_EC2.sh +++ b/run_container_on_EC2.sh @@ -3,7 +3,7 @@ # This script sets authenthicates and pulls docker image. Then runs it on host # Global data -source send_image_to_aws.sh +source ./send_image_to_aws.sh IMAGE_NAME="$ECR_NAME:latest" @@ -22,7 +22,7 @@ echo "Public IP address of EC2 instance: $PUBLIC_IP" # Authorize ECR in docker echo "Getting authentication token for ECR..." -DOCKER_LOGIN_CMD=$(aws ecr get-login-password --region "$REGION" | docker login --username AWS --password-stdin "$ACCOUNT_ID".dkr.ecr."$REGION".amazonaws.com 2>&1) +DOCKER_LOGIN_CMD=$(aws ecr get-login-password --region "$REGION" | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID".dkr.ecr."$REGION".amazonaws.com 2>&1) if [[ $DOCKER_LOGIN_CMD == *"Login Succeeded"* ]]; then echo "Authentication with ECR successful." diff --git a/send_image_to_aws.sh b/send_image_to_aws.sh index 9fbda7cc2..3652a3b1b 100644 --- a/send_image_to_aws.sh +++ b/send_image_to_aws.sh @@ -5,7 +5,7 @@ # Note: docker is reqiured # Global data -source prepare_aws_enviroment.sh +source ./prepare_aws_enviroment.sh AWS_ACCOUNT_ID="" DOCKERFILE_DIR=""