I know it seems weird to deploy two applications on one AWS EBS but there are really such cases when you might want to do that. I wanted and I succeeded. See how.
Why two application on the same Elastic Beanstalk container?
Usually, people create an AWS EBS instance for a single application. If the application is small, they use a micro server. If it is big, they built the environment on a bigger server. If the expected usage is huge, there is also clustering available. But why would anyone want to use a single EBS for more than one application?
I can defend only myself. I had two tiny applications that used the same database and all I needed is to make it available from the internet for testing purposes as cheap as possible. I knew that the traffic would be minimal so it made sense for me to use a single environment for both applications. At least for the time being.
ZIP package deployment
You can deploy WAR or ZIP file to AWS EBS. This is what I used to achieve my goal. I had two applications - each of them packed to a single WAR file:
- a.war
- b.war
I needed to compress both files to a zip file - combined.zip.
Deployment of the zipped file is exactly the same as in case of a single WAR file.
I went to the AWS Console. Elastic Beanstalk. I created an environment in the exact same manned I would create one for a single application. I uploaded and deployed my ZIP file instead of a WAR file.
Both applications are available on the same environment and server so both have the same URL except contexts. The contexts come from WAR file names so URLs are like below:
- http://two_apps-env.something.something.elasticbeanstalk.com/a/
- http://two_apps-env.something.something.elasticbeanstalk.com/b/
It is pretty straightforward once you know that a ZIP file can be deployed to AWS EBS.