$ brew tap tilfin/aws
A script to ssh EC2 instances to be selected from the list shown for specified profile
$ brew install ec2ssh
$ ec2ssh <aws profile>
- If switching profile needs your MFA token,
Enter MFA code>
is shown. - SSH user is fixed to ec2-user.
- If your need pre hook, put
~/.ec2ssh-pre
file. - If your need post hook, put
~/.ec2ssh-post
file.
- If target EC2 needs the connection via a bastion server,
bastion
in pre hook - If target EC2 needs the routing (via VPN), add a route in pre hook and delete the route in post hook.
case $profile in
brand-x)
bastion=brand-x-bastion
;;
brand-y)
sudo route add 50.200.200.100 192.168.50.1
;;
esac
case $profile in
brand-y)
sudo route del 50.200.200.100
;;
esac
A script to switch an assume role for terminal shell
$ brew install swrole
$ swrole [-o] <aws profile>
- Enter forked bash that export AWS_XXX environments without
-o
option - Print AWS_XXX environments with
-o
- Be careful that session will be expired in a hour.