From adf0b40809436be96e7424e8c2aab52793ff16a3 Mon Sep 17 00:00:00 2001 From: Arkadii Yakovets Date: Wed, 25 Oct 2023 08:51:19 -0700 Subject: [PATCH] Add API server SSH connection check --- infrastructure/deploy.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/infrastructure/deploy.sh b/infrastructure/deploy.sh index a10e663a9..1d9c722a9 100755 --- a/infrastructure/deploy.sh +++ b/infrastructure/deploy.sh @@ -340,6 +340,17 @@ terraform apply -var-file="environments/$env.tfvars" -auto-approve chmod 600 data-refinery-key.pem API_IP_ADDRESS=$(terraform output -json api_server_1_ip | tr -d '"') +# Check SSH connection. +if ! ssh -o StrictHostKeyChecking=no \ + -o ServerAliveInterval=15 \ + -o ConnectTimeout=5 \ + -i data-refinery-key.pem \ + "ubuntu@$API_IP_ADDRESS" "exit"; then + exit_code=$? + echo "Could not SSH into the API server. Did you rotate the SSH keys recently?" + exit $exit_code; +fi + # To check to see if the docker container needs to be stopped before # it can be started, grep for the name of the container. However if # it's not found then grep will return a non-zero exit code so in that