Today I released a Python script called quick-deploy-java that makes it easier to deploy multiple Java applications (WARs) to a single Elastic Beanstalk instance.
Want to give it a shot? Clone the repo and follow along with this tutorial.
Step 1: Create a directory for your application and navigate to that directory
We’ll call this
eb-test. We assume that you’ll do this from the same directory that this
TUTORIAL.md file is located. If you do not the instructions later will need to incorporate the proper paths.
Step 2: Run
eb init to create your application in Elastic Beanstalk
I used the following values:
Region – us-east-1
1 2 3 4 5 6 7 8 9 10 11
Application name – eb-test
1 2 3
Platform – Tomcat
1 2 3 4 5 6 7 8 9 10 11 12
Platform version – Tomcat 8 Java 8
1 2 3 4 5 6 7
SSH – yes
Keypair – existing
I already had a keypair called aws-eb that I use. You can reuse an existing one or create a new one. It shouldn’t matter.
1 2 3 4
Step 3: Create a testing environment
Since no applications are in this directory it will also launch the sample application. On my system this step took about 4 minutes.
The output you’ll see will start with something similar to this:
1 2 3 4 5
Once it is done you’ll see this:
Step 4: Validate that the default environment is running
You should see a page in your web browser that looks like this:
Step 5: Deploy the first toy application by itself
1 2 3 4 5
This may take several minutes. Once it is complete you can verify that it is running by doing this:
In your browser you should see a simple page that says something like this:
The random number at the end will be different.
At this point you’ve deployed a single application to a single instance. Now we’ll deploy three applications to the same instance.
Step 6: Deploy three applications to the same instance
1 2 3 4 5 6 7
This took about 4 minutes on my system. At this point open the application again:
Make sure that the random number has changed. This shows that you’ve got a new instance of the application.
/1 to the URL in your address bar and load the page. You should see the same message but again with another new number. This shows that you have a second copy of the application running at a new path.
/2 in the URL in your address bar and load the page. You should see exactly this message in your browser:
If everything worked out you now have an Elastic Beanstalk configuration that is running three applications in a single instance.
application1 is running at the root and at the
1 path while
application1 is running at the
Step 7: Terminate your application
Make sure you terminate your application when you’re done.
If you forget to do this step Amazon will keep your application running and keep billing you! If you want to be extra thorough go into the AWS Elastic Beanstalk console and delete the application completely.
You should also go into S3 and delete any files that are left behind. They don’t take up much space but keeping S3 tidy for when you start making real use of Elastic Beanstalk makes sense.