Getting Started / Hands-on / ...
Set up the Elastic Beanstalk Command Line Interface
With AWS Elastic Beanstalk and AWS Identity and Access Management (IAM)
In this step-by-step tutorial, you will set up the Elastic Beanstalk Command Line Interface (EB CLI). This is part one of a two-part tutorial. In the second half of EB CLI tutorial, you will deploy and monitor an application on the AWS cloud.
Elastic Beanstalk (EB) is a service used to deploy, manage, and scale web applications and services. You can use Elastic Beanstalk from the AWS Management console or from the command line using the Elastic Beanstalk Command Line Interface (EB CLI). You should use the EB CLI as part of your everyday development and testing cycle when you favor using the terminal.
You can use EB with popular languages and frameworks including Node, PHP, Java, Python, Ruby, .NET/IIS, Tomcat, Docker, and Multi-Container Docker.
During this part of the EB CLI tutorial, you will set up a user with the proper permissions then install the EB CLI.
This tutorial requires an AWS account
There is no additional charge for AWS Elastic Beanstalk. The resources you create in this tutorial are Free Tier eligible.
Step 1. Create and set up an IAM user
In this step, you will create an IAM user and grant access for the user to use AWS from the command line. Next, you will grant the user an Elastic Beanstalk IAM permission. Finally, you will download the user credentials for use later in the tutorial.
1. Open the AWS Identity and Access Management (IAM) console. In the navigation pane on the left, select Users.
( click to enlarge )
b. Then select Add user.
( click to enlarge )
c. In the User name field, enter eb-admin. To use the EB CLI with the eb-admin user, it needs programmatic access to AWS. But to use the EB CLI, eb-admin does not need access to the AWS Management console. Understanding that, for Access type check Programmatic access and leave AWS Management Console access unchecked. Then select Next: Permissions.
( click to enlarge )
d. Select the large Add user to group button then select Create group.
( click to enlarge )
e. In the Group name field, enter eb-admins. In the policy section of this screen, you need to select the IAM policy which grants members of the group full access to Elastic Beanstalk.
In the policy search box, type AWSElasticBeanstalkFullAccess.
Select the checkbox next to AWSElasticBeanstalkFullAccess and select Create group.
( click to enlarge )
f. You will see eb-admin created with the AWSElasticBeanstalkFullAccess policy attached to the group. Select Next: Review.
( click to enlarge )
g. Review your user details and permissions. Select Create user.
( click to enlarge )
h. In a later step, you will need to use eb-admin's access key from this page. Save the access key and secret access key on your workstation by selecting Download .csv. Select Close.
( click to enlarge )
Step 2. Install the EB CLI
In this step, you will install the EB command line interface. Follow the OS specific configuration steps below.
-
Windows
-
Linux
-
macOS
-
Windows
-
a. Download and install Python 3.6+ by going to the Python Software Foundation website and choose the version of Python for your OS. Make sure and select Add Python to environment variables in the Python installer so Python will work from any command line location. The Python installer will install Python and the pip package manager.
( click to enlarge )
b. Start the Windows Command Prompt using the Run Window (Win +R on your keyboard) and typing cmd then pressing Enter.
c. Using the Windows Command Prompt, confirm that Python is installed properly by running:
python --version
d. Using the Windows Command Prompt, confirm that pip is installed properly by running:
pip --version
e. Now that Python and pip has been installed, install the EB CLI by running:
pip install awsebcli --upgrade --user
f. Now confirm that the EB CLI is installed correctly by running:
eb --version
-
Linux
-
a. Your modern Linux distro probably includes Python by default. Confirm that Python is installed by starting a terminal session and running the following command:
python -–version
If your Python Version is 2.7, continue with these installation instructions.
If your Python is greater than 2.7, do not use these installation instructions. Use the comprehensive EB CLI installation instructions.
b. Now confirm that the pip Python package manager is installed by running the following command:
pip -–version
c. Now that Python and pip have been verified, install the EB CLI by running:
pip install awsebcli --upgrade --user
d. Now confirm that the EB CLI is installed correctly by running:
eb –-version
-
macOS
-
a. Start the MacOS terminal application.
b. If you have the Homebrew package manager on your mac, update your homebrew fomulae by running the following command in Terminal:
brew update
If you don't have the the Homebrew package manager installed, install it by running the following command in Terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
c. Using Homebrew, install the EB CLI by running the following command in Terminal:
brew install awsebcli
d. Now confirm that the EB CLI is installed correctly by running:
eb --version
Congratulations!
Congratulations, you have set up the Elastic Beanstalk Command Line Interface. You should use the EB CLI to deploy and manage applications whenever you want the power of Elastic Beanstalk from the command line.