Hello Readers! In this blog we will see how to deploy any application in AWS Beanstalk using the EB Command line interface. In my previous blog we have seen how to install EB CLI. So, to follow further steps for deploying an application firstly you need to install its CLI.
Do refer my blog for installation: https://blog.knoldus.com/how-to-setup-eb-cli/
So, Let’s get started!
Step 1: Check its version
Step 2: Make an application for Deploying
Here I am making a simple index.html file for deployment in Elastic Beanstalk.
Paste your code in this file.
Step 3: Create Environment
Firstly initialize your environment and it will ask for the region where you want to deploy your application. By default it takes 3 which is Oregon.
I will select 6 here, which is the Mumbai region.
Then it will ask for the application name. Enter this as per your wish.
It will ask for selecting runtime. Let’s use the latest one.
If you want to set up your ssh for your instance enter yes.
If you have a key pair it will list here otherwise it will ask here the name you want to give for your key pair.
Now, initialization is done!
Step 4: Create EB
Run this command and it will ask a couple of questions. Follow these steps. Enter Environment name here.
Then enter the DNS name here. Select a load balancer type: let’s go with the default one which is application.
Now it will create. You can see the events here. It’s starting the environment.
It has actually uploaded an index.html file as a zip file in s3 bucket. It’s creating aws instance. It will take some time and after that it will be finished.
Lets check by listing by following command:
Step 5: Open EB in your aws account and refresh it.
We can see here that the environment we created is green and healthy. And you will get an url where you can see your application.
If you want to configure your application use the following command:
If you want to see logs use following command:
We can also check the health by command line the command is:
If you want to see the health continuously i.e it will auto refresh then use the flag –refresh:
If you want to list the events use the following command:
We can also check the status of the environment through command line:
If you want to open your application url from your terminal then follow this command:
Now at last if you want to terminate your environment the command is:
It will take a little time because it needs to delete a lot of resources created i.e ec2, auto scaling group, target group, load balancer, alarms, security groups etc. However it will not delete s3 bucket you have to delete it manually.
For deleting s3 bucket you have to firstly delete the bucket policy.
And after that you can delete s3 bucket:
Now you have successfully terminated everything.
In this blog we have seen how to deploy any application in AWS Beanstalk using the EB Command line interface. And we have also seen various commands used in Elasticbeanstalk. Thanks for being with me till the end. If you find this blog helpful do share with your friends.