これはなに
Elastic Beanstalk CLI を利用していると eb ssh your-env-name
コマンドを使って、
任意のインスタンスに SSH 接続することができます。
けれど毎回環境名を記述するのは面倒ですよね。
そこで peco を使ってインタラクティブに環境を選択デキるようにしちゃいましょう!
事前準備
実装
.zshrc
や .bashrc
にコマンドを追加します。
.zshrc
function ebssh {
F=$(eb list | peco)
if [ $? -eq 0 -a "${F}" != "" ]
then
echo "SSH to ${F}..."
eval "eb ssh ${F}"
fi
}
読み込みしなおして...
$ source ~/.zshrc
あとはプロジェクトディレクトリでコマンド打って
$ ebssh
peco から環境を選択すると
QUERY>
xxx-dev
xxx-prd
xxx-stg
xxx-stg-20151001
xxx-stg-20151004
接続できます!便利!
SSH to xxx-prd-20151004...
INFO: Attempting to open port 22.
INFO: SSH port 22 open.
Last login: Fri Oct 9 02:46:41 2015 from xxxxx
_____ _ _ _ ____ _ _ _
| ____| | __ _ ___| |_(_) ___| __ ) ___ __ _ _ __ ___| |_ __ _| | | __
| _| | |/ _` / __| __| |/ __| _ \ / _ \/ _` | '_ \/ __| __/ _` | | |/ /
| |___| | (_| \__ \ |_| | (__| |_) | __/ (_| | | | \__ \ || (_| | | <
|_____|_|\__,_|___/\__|_|\___|____/ \___|\__,_|_| |_|___/\__\__,_|_|_|\_\
Amazon Linux AMI
This EC2 instance is managed by AWS Elastic Beanstalk. Changes made via SSH
WILL BE LOST if the instance is replaced by auto-scaling. For more information
on customizing your Elastic Beanstalk environment, see our documentation here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
[ec2-user@ip-xxxxx ~]$