【AWS】ebコマンドのインストール方法

Web開発

皆さん、こんにちは!

AWSのElastic BeanstalkのCLIコマンドであるebコマンドを使用するために、インストールしたのでメモ程度に書いておきます。

基本的に以下に記載してある通りにやればOKです!

GitHub - aws/aws-elastic-beanstalk-cli-setup: Simplified EB CLI installation mechanism.
Simplified EB CLI installation mechanism. Contribute to aws/aws-elastic-beanstalk-cli-setup development by creating an account on GitHub.

今回試した環境情報

OS: CentOS7(VM)

ebコマンドのインストール方法

gitはインストールされている前提で書いてます。

もしまだinstallしていないなら、以下でできます。

# yum install git

ebコマンドをインストールするために必要なパッケージをインストールする。

# yum groupinstall "Development Tools"
# yum install zlib-devel openssl-devel ncurses-devel libffi-devel sqlite-devel.x86_64 readline-devel.x86_64 bzip2-devel.x86_64

gitのリポジトリからCLI用のインストーラーをクローンする。

# git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
Cloning into 'aws-elastic-beanstalk-cli-setup'...
remote: Enumerating objects: 295, done.
remote: Total 295 (delta 0), reused 0 (delta 0), pack-reused 295
Receiving objects: 100% (295/295), 508.25 KiB | 264.00 KiB/s, done.
Resolving deltas: 100% (163/163), done.

クローン先でインストーラーを実行する。

と、以下のような感じでインストールされる。

# ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer

==============================================
I. Installing Python                          
==============================================

*************************************************************
1. Determining whether pyenv is already installed and in PATH
*************************************************************
    - pyenv found in PATH. Won't clone pyenv git repository from GitHub

*******************************************
2. Temporarily export necessary pyenv paths
*******************************************

****************************************************************************
3. Checking whether Python can be downloaded (through curl, wget, or aria2c)
****************************************************************************

************************************************************
4. Installing Python 3.7.2. This step may take a few minutes
************************************************************
Downloading Python-3.7.2.tar.xz

...

******************************************************************
5. Installing virtualenv using /root/.pyenv/versions/3.7.2/bin/pip
******************************************************************
Collecting virtualenv
  Downloading 

...

==============================================
II. Creating self-contained EBCLI installation
==============================================

******************************************
1. Creating exclusive virtualenv for EBCLI
******************************************
created virtual environment CPython3.7.2.final.0-64 in 1669ms
...

************************
2. Activating virtualenv
************************

*******************
3. Installing EBCLI
*******************
Collecting awsebcli
...

***********************
4. Creating EB wrappers
***********************

***************
5. Finishing up
***************
Success!

    Note: To complete installation, ensure `eb` is in PATH. You can ensure this by executing:

    1. Bash:

       echo 'export PATH="/{HOME_DIR}/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile

 ...

上の最後の方に書かれている通りに、パスを通せばebコマンドが使えるようになる。

# echo 'export PATH="/{HOME_DIR}/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile

ebコマンドをたたいてみて、動作を確認する。

以下のように出力されればOK。

# eb
usage: eb (sub-commands ...) [options ...] {arguments ...}

Welcome to the Elastic Beanstalk Command Line Interface (EB CLI). 
For more information on a specific command, type "eb {cmd} --help".

commands:
  abort        Cancels an environment update or deployment.
  appversion   Listing and managing application versions
  clone        Clones an environment.
  codesource   Configures the code source for the EB CLI to use by default.
  config       Modify an environment's configuration. Use subcommands to manage saved configurations.
  console      Opens the environment in the AWS Elastic Beanstalk Management Console.
  create       Creates a new environment.
  deploy       Deploys your source code to the environment.
  events       Gets recent events.
  health       Shows detailed environment health.
  init         Initializes your directory with the EB CLI. Creates the application.
  labs         Extra experimental commands.
  list         Lists all environments.
  local        Runs commands on your local machine.
  logs         Gets recent logs.
  open         Opens the application URL in a browser.
  platform     Commands for managing platforms.
  printenv     Shows the environment variables.
  restore      Restores a terminated environment.
  scale        Changes the number of running instances.
  setenv       Sets environment variables.
  ssh          Opens the SSH client to connect to an instance.
  status       Gets environment information and status.
  swap         Swaps two environment CNAMEs with each other.
  tags         Allows adding, deleting, updating, and listing of environment tags.
  terminate    Terminates the environment.
  upgrade      Updates the environment to the most recent platform version.
  use          Sets default environment.

optional arguments:
  -h, --help            show this help message and exit
  --debug               toggle debug output
  --quiet               suppress all output
  -v, --verbose         toggle verbose output
  --profile PROFILE     use a specific profile from your credential file
  -r REGION, --region REGION
                        use a specific region
  --no-verify-ssl       don't verify AWS SSL certificates
  --version             show application/version info

To get started type "eb init". Then type "eb create" and "eb open"

ではでは!

タイトルとURLをコピーしました