forked from nasa/cumulus-template-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint-connection-commands.sh
33 lines (22 loc) · 1.14 KB
/
print-connection-commands.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -e
ec2_instance_id=$(aws ec2 describe-instances --filters "Name=tag:Deployment,Values=[$PREFIX]" "Name=instance-state-name,Values=running" | jq -r ".Reservations[0].Instances[].InstanceId")
cd deploy/cumulus-tf
api_gateway_uri=$(../../terraform output | grep "archive_api_uri" | sed 's/.* = \(.*\)/\1/')
api_gateway=$(../../terraform output | grep "archive_api_uri" | sed 's/.*https:\/\/\(.*\):.*/\1/')
api_gateway_redirect_uri=$(../../terraform output | grep "archive_api_redirect_uri" | sed 's/.* = \(.*\)/\1/')
echo "
# API Connection via tunneling
## Create local port:
aws ssm start-session --target $ec2_instance_id --document-name AWS-StartPortForwardingSession --parameters portNumber=22,localPortNumber=4343
## Configure with path to keypair and run in a separate terminal to create the tunnel:
ssh -p 4343 -N -L 8000:$api_gateway:443 ec2-user@localhost -i path/to/keypair
## Add to your /etc/hosts file:
127.0.0.1 $api_gateway
## Test your endpoint
curl "$api_gateway_uri"version
## Add the redirect API to your Earthdata Login application
$api_gateway_redirect_uri
## APIROOT for your dashboard
APIROOT=$api_gateway_uri
"