What is AWS Elastic Beanstalk and how to deploy simple HA web application
Tags: beginners, aws, cloud
Published: 2022-03-28 14:01:45

AWS elastic beanstalk (EB) is developer centric view of deploying an application using aws components like ec2, asg, elb, rds and etc.  EB is free service and only pay for the underly infrastructure.  Fast simple and customizable.  EB support multiple languages like Go, Java, .Net, Node js, PHP, Python, Ruby and so on.  It is aws fully managed service.

![AWS Elastic Beanstalk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t71l7e3zvjmvp1klcby6.png)
Before any eb deployment make sure create IAM role called aws-elasticbeanstalk-service-role with these eb policies:

- AutoScalingFullAccess
- ElasticLoadBalancingFullAccess
- AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy

![IAM Role Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctdfv2bi6h7ksm6hci9x.png)

Here how to deploy sample web ha app using aws elastic beanstalk:

Go to AWS Elastic Beanstalk console: https://console.aws.amazon.com/elasticbeanstalk and click **Create Application**. 

- Give your application name at Application name area & choose the platform at platform section.

![EB Sample App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3caytb7otpl5263hwkmp.png)

- In the Application code section you have to choose a sample application and the click on Configure more options

![EB Sample App Configure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ry2a65sfadyjbf3os0th.png)

- Select High Availability at Configuration Presets section area

![EB Sample App HA Configure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13lb9dx06ygtcj77w3or.png)

- At Capacity section click edit and enter desire number of instances at Auto Scaling Group and click Save at bottom.

![EB Sample App ASG Configure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1r5a7ffsayccx3tt3zj.png)

![EB Sample App ASG Configure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id8u0nzixitkellngonw.png)

- At Network section click edit and choose VPC, Load balancer settings and Instance subnets and click Save. (Only of not using default VPC) this example is not using default VPC. 

![EB Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyqv12riuhqxefy2fbz5.png)

![EB LB setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lo0v8n2jsvgxvuqh4e9u.png)

![EB Subnets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpskmt98i8bq4yh1aln8.png)

- At the Load balancer section and click Edit and select Application Load Balancer at Load balancer type area, then click Save at bottom. 

![EB Application LB](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lw9lk9kefs0e5pvqznew.png)

![EB Application LB](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzlt45zr1ar6rzbjjbdb.png)

- At Security section click edit and enter "ec2 keypair" if require to login (ssh) to ec2 instances.

![EB ec2 keypair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2exvz1zaqa51v4v679fm.png)

- Finally, at Rolling updates and deployments section click edit and update desire update Deployment policy.  Click Save at bottom.

![EB update policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngiwcaebyamth5ewo1t3.png)

![EB update setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hac5gpnnvqdx5uf0f754.png)

- After all configuration updates Click Create app at bottom.

![EB create app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/la9qryt6qd9jf3g1py8o.png)

- Here are events and at the end Green check mark with environment url. 

![EB deployment output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6wk6ornv3ykk6zkfq3u.png)

- Environment overview page

![EB environment overview page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u0ujxed0taumyvi7f0h5.png)

**Congratulations you are successfully deployed Web App using AWS Elastic Beanstalk!**