Added variable session timeout

This commit is contained in:
2020-05-27 22:43:03 +02:00
parent 4fceb63f2a
commit 52f484f4f8

View File

@ -22,13 +22,14 @@ function ssm_tunnel --description 'access private AWS ressources via Bastion Hos
# Ports to bind for forwarding # Ports to bind for forwarding
set LOCAL_PORT $argv[2] set LOCAL_PORT $argv[2]
set REM_PORT (math (random) % 65535 + 2000) set REM_PORT (math (random) % 65535 + 2000)
set TIMEOUT 21600 #seconds until forwarding session times out (48h max)
# make sure jq is installed # make sure jq is installed
# Start socat on the remote server # Start socat on the remote server
set CMD "'sudo socat TCP4-LISTEN:$REM_PORT,fork TCP4:$REMOTE_HOST'" set CMD "'sudo socat TCP4-LISTEN:$REM_PORT,fork TCP4:$REMOTE_HOST'"
set CMD_INVOC_ID (aws ssm send-command --instance-ids $INSTANCE_ID \ set CMD_INVOC_ID (aws ssm send-command --instance-ids $INSTANCE_ID \
--document-name 'AWS-RunShellScript' \ --document-name 'AWS-RunShellScript' \
--parameters commands=$CMD --output json | jq -r '.Command.CommandId') --parameters "commands=$CMD,executionTimeout=$TIMEOUT" --output json | jq -r '.Command.CommandId')
# Start tunnel session # Start tunnel session
echo "Starting Tunnel" echo "Starting Tunnel"