Working with the Elastic Beanstalk CLI

With your environment deployed using the AWS Management Console, we now shift our focus to leveraging the Elastic Beanstalk CLI, or EB CLI, to push the application code over to the newly created environment.

The EB CLI is a powerful utility that can be used to operate and manage your entire Elastic Beanstalk environment using a few simple CLI commands. It is also designed to work with AWS development services such as CodeBuild and CodeCommit, as well as other third-party code repository services such as Git.

In this section, we will first be looking at a few simple steps for installing the EB CLI on a simple Linux instance, later followed by configuring and pushing our WordPress application to its respective development environment:

  1. To do so, we first need to ensure that the instance is updated with the latest set of packages. In my case, I'm performing the steps on a simple Ubuntu 14.04 LTS instance, however, you can alternatively use your own on-premises virtual machines.
  2. Run the following command to update your OS. The command will vary based on your operating system variant:
# sudo apt-get update
  1. Next, we need to ensure that the instance has the required Python packages installed in it. Note that if you are using the Amazon Linux AMI, then by default it will already have the necessary Python packages installed in it:
# sudo apt-get install python python-pip
AWS CLI and the EB CLI require Python 2 version 2.6.5+ or Python 3 version 3.3+.
  1. With the Python packages installed, we now move forward and set up the AWS CLI using the following commands:
# pip install awscli
# aws configure
The first command installs the CLI, while the other runs you through a simple wizard to set up the AWS CLI for your instance. To learn more about how to configure the AWS CLI, you can check out this URL: http://docs.aws.amazon.com/cli/latest/userguide/installing.html.
  1. Finally, we go ahead and install the EB CLI. The installation is pretty straightforward and simple:
# pip install awsebcli
  1. That's all there is to it! You now have a functioning Elastic Beanstalk CLI installed and ready for use. So let's now go ahead and download the required WordPress code ZIP file locally and use the EB CLI to push it into the development environment:
# sudo git clone https://github.com/WordPress/WordPress.git
  1. Extract the contents of your WordPress ZIP file into a new folder, and run the following command from within the WordPress directory:
# eb init

The eb init command is used to initialize and sync the EB CLI with your newly created development environment. Follow the on-screen instructions to configure the EB CLI's settings, such as Selecting a default region to operate from, Selecting an application to use, and so on. Remember, the default region has to match your current development environment's region as well, which in my case is us-east-1:

  1. With the EB CLI set up, the only step left now is to deploy the WordPress application to the development environment using yet another EB CLI command called simply eb deploy:
# eb deploy

During the deployment process, the CLI creates an application version archive in a new S3 bucket within your environment. Each application deployment will result in subsequent version creations within S3 itself. After this, you will see your application code get uploaded to your development environment, as depicted in the following screenshot:

  1. The environment simultaneously changes its state from Ok to Pending as the application is uploaded and set up in your development instance. Once the application becomes available, the health state of the environment will yet again transition from Pending to OK to Info.
  2. You can verify whether your application has uploaded or not by refreshing the application URL (yoyoclouds.us-east-1.elasticbeanstalk.com) on your environment's dashboard. You should see the WordPress welcome screen, as shown in the following screenshot:

Note, however, that this setup still requires a MySQL database, so don't forget to go to the RDS Management Console and create a minimalistic MySQL database, or even better, an Aurora DB instance, for your development environment. Remember to note down the database username, password, and the DB host and database name itself; you will need these during your WordPress configuration!

With this step completed, let's take a few minutes to understand the various options for configuring and monitoring your newly deployed application using the environment dashboard!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset