Chen Jian's Java Blog 

Things to do for a serious Java website when using Elastic Beanstalk

by Chen Jian


Posted on 2018-11-25 12:32 in Java


Before you start

Get a domain

If you haven't got one, you can buy one. You can get it from AWS Route 53

Get a SSL certificate for your domain

You can get it from AWS Certificate Manager.

Create an IAM User

You will need this user's access key and access secret to run eb-cli

Create a keypair

You need this to ssh login to your EC2 instance

Some limitations to your code

  • You application should listen to port 5000. Beanstalks' included nginx will map it to 80
  • Don't let your app read from System.getProperty(), but from System.getEnv(), if you don't want to add any other file other than your *.war/*.shaded-jar to upload to Beanstalk. Tnat's because Beanstalk can take enviroment properties only by default
  • Let all your log4j loggers write to console instead of any file. Console outptu will be automatically collected by Beanstalk
  • Let your webapp have a health check url, which can be configured with Beanstalk's load balancer

Create your beanstalk application

You can do this with the web console or eb-cli

After application created

  • Add a CNAME to your own domain. So www.yoursite.com will point to xxx.xxx-beanstalk.com
  • In Beanstalk's load balancer, disable http 80 and enable https 443, use the SSL certificate your got from AWS Certificate Manager
  • Try ssh log-in using eb-cli's "eb ssh".
  • Set up the security group of your RDS, so that you can access it from your local machine



No one has commented yet.
该日志评论功能被禁用了。