AWS Elastic Beanstalk
Elastic Beanstalk is used for very quick deployment of the application/software. It's free as a service but component will be charged. Elastic Beanstalk uses S3 bucket for versioning purpose.
Fig: Elastic Beanstalk Workflow |
Advantages of Elastic Beanstalk:
1. Easy and quick deployment of application
2. Automatically handles the deployment details
3. Highly reliable, highly scalable and cost-effective infrastructure.
4. Can be extended to support multiple development stacks (means you can run multiple application on the same server).
5. Developer retains full control over the AWS resources (means we have SSH login to perform any change in it. BUT in RDS there is only client login).
6. Root access to EC2 instances
7. Easily manage to configure changes in one place (S3 bucket).
8. Use any database - Amazon RDS, Amazon SimpleDB, or oracle (means if require Elastic Beanstalk can also launch an RDS instance).
9. Create custom AMIs
10. We can run other services side-by-side in EC2.
For configuring an Application in AWS Elastic Beanstalk with Load Balancer, we need to follow the steps:
1. Create an application
2. Verify this application
3. Update the configuration
4. Verify logs
5. Configure this application with a load balancer
6. Access to the instance created by Elastic Beanstalk
6. Access to the instance created by Elastic Beanstalk
Step 1: Create an application:
AWS ➔ Services ➔ Elastic Beanstalk ➔ Create New Application ➔ Application Name: webshack-app ➔ Description: This is a Tomcat server for deploying JAVA apps ➔ provide any tag if you want ➔ Create ➔ Environments ➔ Create one now ➔ Web server environment ➔ Select ➔ Environment name: WebshackApp-env (this name will be prompted automatically but if you want you can change this)…
Fig: Environment Information |
…Domain: leave blank for auto generated value ➔ Platform: Preconfigured platform: Tomcat ➔ Application code: you can use sample application or your own code. Here, I am using sample application code for this practice ➔ Create environment ➔
Fig: Logs of Environment Creation |
We can see within a couple of minutes, Elastic Beanstalk created the environment for us. But before that we can see that it has created an Elastic IP, which will be responsible to access the application, then it created a Security Group for us and then it created an S3 bucket to put the JAR/WAR file. Now it's going to launch instance for us and if the instance is launched, means the environment is completely created for us and we can start working with this environment.
Step 2: Verify this application:
As we can see, there is an application URL provided on top of the Elastic Beanstalk Dashboard. So, either we can click on this or also we can use Elastic IP of EC2 instance in the browser.
Fig: Verify the application |
Step 3: Update the configuration:
If you want you can modify the configuration of your instance.
AWS ➔ Service ➔ Elastic Beanstalk ➔ At the bottom of the dashboard there is an application environment, which we created as 'WebshackApp-env', click on this…
AWS ➔ Service ➔ Elastic Beanstalk ➔ At the bottom of the dashboard there is an application environment, which we created as 'WebshackApp-env', click on this…
Fig: List of all applications |
… ➔ Configuration ➔ Click on the 'Modify' under 'Instances'…
Fig: Modify the configuration |
Step 4: Verify Logs:
AWS ➔ Service ➔ Elastic Beanstalk ➔ Select the environment ➔ Logs ➔ Request Logs ➔ Last 100 lines ➔ now, we are able to Download. Just click on Download, and this will display the last 100 lines of logs. But if we click on 'Full logs' this will let us download a zip file for all logs.
Fig: Logs |
Step 5: Configure this application with a load balancer:
AWS ➔ Service ➔ Elastic Beanstalk ➔ click on 'webshack-app' application ➔ Configuration ➔ Click on 'Modify' under Load Balancer
If the Load balancer configuration category doesn't have a Modify button, means your environment doesn't have any load balancer. So now, we need to change the environment type of our application. For this click on 'Modify' under capacity ➔ Environment type: Load balanced…
Fig: Modify capacity |
… Instances: Min: 2 and Max: 4 (as per the requirement) ➔ choose Availability zone, if you want to specify any ➔ (provide all specifications as per the requirement) ➔ Apply ➔ Confirm.
Now, we can see that Load Balancing has been enabled in our application's environment. As we have provided minimum 2 instances into the load balancer, so after full completion of configuration we can see one more instance has been launched in EC2. Also, we can see that the Modify button has been highlighted under 'Load balancer'.
Step 6: Access to the instance created by Elastic Beanstalk:
1) First, create a key pair:
AWS ➔ Service ➔ select Key Pairs under Network & Security ➔ Create Key Pair ➔ Key pair name: give any name ➔ Create. Download .pem file.
Convert .pem file to .ppk file:
Open PuTTYgen ➔ Load ➔ select .pem file ➔ Open ➔ Save Private key ➔ save as .ppk.
2) Now, update Security Key in Elastic Beanstalk:
AWS ➔ Service ➔ Elastic Beanstalk ➔ click on 'webshack-app' application ➔ Configuration ➔ Click on 'Modify' under 'Security' ➔ EC2 key pair: select the keypair which you created ➔ Apply.
Let the configuration be completed and then access the instance using the Elastic IP and keypair which you provided.
AWS ➔ Service ➔ select Key Pairs under Network & Security ➔ Create Key Pair ➔ Key pair name: give any name ➔ Create. Download .pem file.
Convert .pem file to .ppk file:
Open PuTTYgen ➔ Load ➔ select .pem file ➔ Open ➔ Save Private key ➔ save as .ppk.
2) Now, update Security Key in Elastic Beanstalk:
AWS ➔ Service ➔ Elastic Beanstalk ➔ click on 'webshack-app' application ➔ Configuration ➔ Click on 'Modify' under 'Security' ➔ EC2 key pair: select the keypair which you created ➔ Apply.
Fig: Modify Security |
Enjoy!
No comments:
Post a Comment