Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rshell is a tool used to retrieve AWS instances ips by instance name and connects to selected instance via ssh. It is useful when your instances are behind AWS Load Balancer.

Notifications You must be signed in to change notification settings

borisdblade/rshell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rshell is a tool used to retrieve AWS instances ips by instance name, connect to them, execute custom or predefined commands on instances...

It is useful when your instances are behind AWS Load Balancer.

RShell setup

IF YOU HAVE PYTHON AND AWS SET UP ALREADY, SKIP TO STEP#3 Deployment

1. install pip3

Mac:

brew install python3

Linux deb:

sudo apt install python3

2. Install aws client

Mac:

pip3 install awscli

Linux deb:

apt install awscli 

Edit .aws/config, or

aws-configure

.aws/config example

[default]
aws_access_key_id = <access_key_id> 
aws_secret_access_key = <secret_access_key>
region = <your-aws-region>

Chmod

 chmod 600 $HOME/.aws/config

Export environment

 export AWS_CONFIG_FILE=$HOME/.aws/config

3.Deployment

Download or clone this project

And make main file executable

sudo chmod +x rsh.sh

4.Setup RSH

Run the setup from the root of project directory

sh setup.sh

5.Options

List instances

rsh list

Connect:

rsh <instance_name>

Run custom commands:

rsh <instance_name> -custom="cd /var/www/example; touch hello.php;"

Predefined commands:

-git            # git pull
-composer       # composer install; composer du
-rb-cms-update  # updates rb cms on aws s3

And more to come!

THAT IS IT! ENJOY...

Additional info

aws query ip address for specific instance name

aws ec2 describe-instances --filters 'Name=tag:Name,Values=<instance-name>' --output text --query 'Reservations[*].Instances[*].PublicIpAddress'

command example for extracting instance ip

aws ec2 describe-instances --filters 'Name=tag:Name,Values=rb-v2-api' --output text --query 'Reservations[*].Instances[*].PublicIpAddress'

for later :: generate ssh config

aws ec2 describe-instances --output text   --query 'Reservations[].Instances[].[Tags[?Key==`Name`,Values==`rb-v2-api`] | [0].Value, PublicIpAddress]'


aws ec2 describe-instances --filters 'Name=tag:Name,Values=dev-server-*' --output text --query 'Reservations[*].Instances[*].InstanceId'

About

Rshell is a tool used to retrieve AWS instances ips by instance name and connects to selected instance via ssh. It is useful when your instances are behind AWS Load Balancer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages