-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Added a new feature to easily tunnel to specific host using ssm thr…
…ough another host in AWS
- Loading branch information
Alex Lubneuski
committed
Nov 11, 2024
1 parent
341c43d
commit dd4d573
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
INSTANCE_ID="" | ||
|
||
if [ -z $1 ]; then | ||
echo "getting info" | ||
info=$(aws ec2 describe-instances --region us-east-1 --query "Reservations[*].Instances[?Tags[?Key=='Name']|[?Value=='$ORG-infra-bastion-ssm-ec2-$syslevel-0']].[InstanceId,PrivateIpAddress]" --output text | tail -1) | ||
INSTANCE_ID=$(echo "$info" | awk '{ print $1 }') | ||
INSTANCE_IP=$(echo "$info" | awk '{ print $2 }') | ||
if [ -z "$INSTANCE_ID" ]; then | ||
echo "Could not find bastion host. Please contact DevOps" | ||
exit 1 | ||
fi | ||
else | ||
INSTANCE_ID="${1}" | ||
fi | ||
|
||
aws ssm start-session --target "${INSTANCE_ID}" --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"portNumber":["'$2'"],"localPortNumber":["'$3'"],"host":["'$4'"]}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters