AWS ElasticBeanstalk First try
Why AWS Elastic Beanstalk?
A single server instance is good for development but it would be bad for production environment because it’s unable to scale horizontally. Also it’s a waste of money to let a giant instance run 7x24 while we just have a few rushing hours in a day. Therefore, we need to be able to scale horizontally base on the network traffic, server cpu utilization percentage etc.
How to use Elastic Beanstalk?
I will create the Elastic Beanstalk environment by a cloudformation template and make specific server instance change in project artifact’s .ebextension config files.
Cloudformation Template
Let’s begin with a snippet.
1 | AWSTemplateFormatVersion: '2010-09-09' |
NOTE: If we need to have immutable auto scaling, aws:elasticbeanstalk:healthreporting:system -> System Type should be set as “enhanced”.
.ebextensions
How about the software and the script deployment in EC2 instance? How can we refer and use the environment variables in ebextensions? Here is an example
1 | ## Install loggly |
1 | packages: |
Note:
- If we want to contain characters like ‘|’ in commands, the command should be placed inside a single quote.