nSights Talks

AWS Elastic Beanstalk with GitHub Actions

Tutorial Highlights & Transcript

00:00 - What is AWS Elastic Beanstalk
Hi everyone, my name is Moezz ul Haq and today I’m going to be presenting how you can automate your Elastic Beanstalk applications through GitHub actions. What is Elastic Beanstalk? Elastic Beanstalk is an AWS tool, which we can use to deploy and scale our applications. With this tool, we can deploy our code on it and it will automatically create EC2 instances or any other resource that it needs to create. This can be used for web applications and hosting any other application which is visible by the URL. The language that we can use with Elastic Beanstalk is Python, Node.JS, and GO and it also supports many underlying languages. But these are the most common ones. Also with Elastic Beanstalk, you don’t have to pay for Elastic Beanstalk, but you have to pay for the resources that Elastic Beanstalk provisions. For example, if Elastic Beanstalk provisions EC2 instances and a load balancer, you have to pay for all those resources, but Elastic Beanstalk doesn’t cost anything by itself.
01:20 - Use Case
What would be the use case for Elastic Beanstalk? In my case, with GitHub actions, we can use GitHub actions with Elastic Beanstalk to update our application and test our application, and it’s already doing this automatically. You don’t have to have a specific person who goes to the console and goes to an Elastic Beanstalk application and uploads a zip file on Elastic Beanstalk. This can be done with your CLI. You just have to do a commit and a push and your changes can be deployed very easily.
02:00 - Basic Actions Script
These are the basic actions that we use for deploying our application to launch Beanstalk. This section only requires your access secret key, secret key ID, and your region which contains every Elastic Beanstalk application and environment. You have to provide your environment name and application name. This should already be created. It can update them. Also, the version which your application contains should learn how this is handled and the deployment package shown.
02:37 - Diagram
My use case is to just do a simple push to GitHub actions and it will deploy the changes to Elastic Beanstalk. Then those sessions can be visible on the internet, and you can just go on.
02:57 - Demo
This is what our Elastic Beanstalk code looks like. Let me just go over the code real quick. Currently, these Elastic Beanstalk GitHub actions can be run on different branches such as main and Dev. It’s turned on to the latest version. Over here, we are setting the environment name for the Elastic Beanstalk application. If we are using the main branch, then our environment will be set to prod. If we are using the dev branch, the deployment name will be set to dev, and so on. Over here, we are giving the package version. The bracket version will be tagged with the year versus the year then the month, then the hour and minutes. This is how our application version will be tagged. Over here, we are using the Elastic Beanstalk action. We have to provide our access key, access key ID, secret access key, our region of the application name, environment name, the version we are running on above, and the zip file. We are also going to zip our files. All of the files that have the code for the Elastic Beanstalk application, such as those inside the GitHub actions, so it will zip the file and deploy it to Elastic Beanstalk. These are the Elastic Beanstalk images currently deployed. This is the application with images showing Congratulations. This is just a basic single application showing Congratulations over here. But if I can go to the code and update it with, for example, Hello World, and I do a Git Commit and push, it will run an actions job on GitHub and deploy it. This will change to Elastic Beanstalk. In this case, if the job is successful, it will show as a success sign, but if the job has failed it will also tell us that it has failed. Yep, so in our case, the job has deployed successfully so we should see Hello World on our Elastic Beanstalk application for now. So let me just refresh this and open the URL. Our application has been updated.
Jasmeet Singh

Moeez ul Haq

DevOps Support Engineer

nClouds

Moeez is a DevOps Support Engineer at nClouds.