Auto deploy backend service to Elastic Beanstalk - with Database, center logs, load balancer, monitoring and auto scaling.

1. Elastic Beanstalk

Elastic Beanstalk is an orchestration service, with help to manage many AWS service such as EC2, S3, CloudWatch Logs, Elastic Load Balancing, AWS RDS.

  • Create Elastic Beanstalk Application - should be your service name - it will be your service playground. I highly recommend to name application with convention <project_name>_<service_name> - such as eb-demo_user-service
  • Create Environment inside Application - such as development, staging, production

  • Within environment, we can control:

    • Software: App config (eg: env params), log config (can choose from stream logs to CloudWatch Logs or store logs in S3, config to enable AWS X-Ray or not).
    • Instances: EC2 instance will be unit to run this application. Which means if you want to scale out this app, this EC2 instance will be duplicated.
    • Capacity: Scaling config.
    • Load Balancer: Config load balancer listeners, processes and rules.
    • Rolling updates and deployments: Config to update all instance of an environment at once or update one by one.
    • Security: Be careful while changing security; including service role, EC2 key pair, …
    • Monitoring: This is a modules will check service health, and update instance status. Only healthy instances can receive request from Load Balancer. So when update your app successfully, remember to set up health check path.
    • … And some other things like Network, Database… (you can create your Database, or let Elastic Beanstalks control it)

      At this step, application’s environment is created, with env’s params, so all we need to do is deploy code.

2. CodePipeline

AWS CodePipeline is already supported deploying to Elastic Beanstalks. In deploy stage, just choose env matched with source’s branch. For example: branch dev to development env, branch staging to staging env and branch master to production env

3. Route 53

Go to Route53 → Create new Record → Type: A - IPv4 Address → Alias → Point to Elastic Beanstalk URL.

DONE!