Skip to main content

move that script to the archivematica repo

ID
5a6fa81
date
2023-07-21 12:32:54+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
d225051
message
move that script to the archivematica repo
changed files
1 file, 1 addition, 54 deletions

Changed files

wellcome/ssh_to_archivematica (1768) → wellcome/ssh_to_archivematica (150)

diff --git a/wellcome/ssh_to_archivematica b/wellcome/ssh_to_archivematica
index be77edb..ffea8f8 100755
--- a/wellcome/ssh_to_archivematica
+++ b/wellcome/ssh_to_archivematica
@@ -5,57 +5,4 @@ set -o nounset
 
 _ensure_aws_credentials_are_fresh
 
-ENVIRONMENT="${1:-}"
-
-if [[ "${ENVIRONMENT:-}" != "prod" && "${ENVIRONMENT:-}" != "staging" ]]
-then
-  echo "Usage: ssh_to_archivematica <prod|staging>" >&2
-  exit 1
-fi
-
-SECURITY_GROUP_ID=$(
-  AWS_PROFILE=workflow-dev aws ec2 describe-security-groups \
-    | jq .SecurityGroups \
-    | jq "map(select(.GroupName | startswith(\"archivematica-$ENVIRONMENT-bastion_ssh_controlled_ingress\")))" \
-    | jq -r '.[0].GroupId'
-)
-
-MY_IP=$(curl -q 'https://ifconfig.me')
-
-set +o errexit  # InvalidPermission.Duplicate
-AWS_PROFILE=workflow-dev aws ec2 authorize-security-group-ingress \
-  --group-id "$SECURITY_GROUP_ID" \
-  --protocol tcp \
-  --port 22 \
-  --cidr "$MY_IP/32"
-set -o errexit
-
-BASTION_HOST=$(
-  AWS_PROFILE=workflow-dev aws ec2 describe-instances \
-    | jq '.Reservations' \
-    | jq 'map(.Instances) | flatten' \
-    | jq 'map(.Tags |= from_entries)' \
-    | jq "map(select(.Tags.Name | startswith(\"archivematica-$ENVIRONMENT-bastion\")))[0]" \
-    | jq -r '.PublicDnsName'
-)
-
-CONTAINER_HOST=$(
-  AWS_PROFILE=workflow-dev aws ec2 describe-instances \
-    | jq '.Reservations' \
-    | jq 'map(.Instances) | flatten' \
-    | jq 'map(.Tags |= from_entries)' \
-    | jq 'map(select(.State.Name == "running"))' \
-    | jq "map(select(.Tags.Name | startswith(\"archivematica-$ENVIRONMENT-container\")))[0]" \
-    | jq -r '.PrivateIpAddress'
-)
-
-echo "BASTION_HOST=$BASTION_HOST"
-echo "CONTAINER_HOST=$CONTAINER_HOST"
-
-scp -i ~/.ssh/wellcomedigitalworkflow \
-  ~/.ssh/wellcomedigitalworkflow \
-  "ec2-user@$BASTION_HOST:wellcomedigitalworkflow"
-
-ssh -t -i ~/.ssh/wellcomedigitalworkflow \
-  "ec2-user@$BASTION_HOST" \
-  ssh -t -i wellcomedigitalworkflow "ec2-user@$CONTAINER_HOST"
+~/repos/archivematica-infrastructure/ssh_to_archivematica "$@"