In our previous blog, How to build and run scalable, secure & containerized Web Applications in minutes using AWS App Runner (Part 1)? We have discussed the recently launched AWS service App Runner, its benefits, use cases, features, architecture, etc. Refer to the following image for a quick recap:
AWS App Runner makes it easier to deploy web applications and APIs to the cloud, regardless of the language they are created in, even for teams with no prior expertise with container deployment or infrastructure management. The service incorporates AWS operational and security best practices and automatically scales up or down on demand, with no need to worry about cold starts. App Runner can deploy your application by either connecting to a container registry or to your source code. In this blog, we will see how we can deploy a scalable and secure web application within minutes. We will explore the App Runner dashboard and look at its various features and benefits for the same. We will then create an App Runner service following a 4 step process and thereby deploying and accessing the application via a default link provided by the App Runner service or using a custom domain (if required). We will also look at how we can redeploy the changes on the web application if any changes are made in the code base.
Hands-on
In this hands-on, we will see how we can make use of the AWS App Runner service to deploy a scalable and secure web application within minutes. AWS App Runner makes it easier to deploy web applications and APIs to the cloud, regardless of the language they are created in, even for teams with no prior expertise with container deployment or infrastructure management. App Runner can deploy your application by either connecting to a container registry or to your source code. We will first create a new repo on our GitHub account and then connect to the source code via the AWS App Runner Console by authorizing access to AWS. We will then explore the AWS App Runner dashboard to have a look at its various features, benefits, use cases, etc. Then we will be creating an App Runner service and finally thereby following a 4 step process, we will connect to the GitHub repo and deploy the source code in the repo which can then be accessed using the default link. We will also look at how we can create custom domains for the application as well as how we can redeploy the application if certain code changes occur in the code base so that the changes are reflected on the application. Refer to the following diagram to understand the architecture of the application implementation:
To implement this, we will do the following:
- Login to your AWS console and navigate to the AWS console.
- Clone the code base to your local machine.
- Navigate to your GitHub account and push the code base in a new repo you create.
- Search for the AWS App Runner service and navigate to its dashboard.
- Select your preferred region (based on the availability of service in that region).
- Explore the AWS App Runner dashboard for its features, pricing, use cases, etc.
- Create a new App Runner service.
- Follow the 4 step process to create a service.
- Authorize AWS to connect to your GitHub repo.
- Configure a new connection and install the AWS connector to the repo that contains the code base.
- Load the repo and the branch that has the code base.
- Configure the Source and Deployment settings.
- Configure the Build settings.
- Configure the service settings for security, health checks, autoscaling, etc.
- Explore the service dashboard and the various offerings by the AWS App Runner service.
- Create a custom domain (if needed).
- Navigate to the default link and test if the application has been deployed successfully.
- For any code changes, redeploy the application from the dashboard and test the application on the custom domain or the default link (as configured).
Login to your AWS console and navigate to the dashboard.
Create a new folder on your desktop to clone the code we used for this blog. Open git bash in the same folder and type in the command:
git clone https://github.com/workfall/aws-app_runner.git
You will have the entire code base cloned in your folder as shown in the image below.
Now, login to your git account, create a new repository, and push the entire code base to your newly created repository since we will be using the same code configuration for this blog.
Search for the AWS App Runner service and click on it to navigate to the homepage of App Runner.
For us, the selected region was Singapore so AWS navigated us to the page which shows only the regions that support AWS App Runner as of now. Click on any one of the available regions as per your requirements.
You will then be navigated to the AWS App Runner homepage. Over there, you can view how it works as well the costs of compute and the add-on costs.
Scroll down and you will see the benefits and the various features offered by AWS App Runner.
Scroll down even more and you will see the various use cases and the related services to AWS App Runner. Now, scroll to the top and click on Create an App Runner Service.
You will be navigated to the creation dashboard wherein you will have to follow a 3-step process to configure and create the service.
Under the source sub section, select Source code repository since we will be executing the code base from the git repo. Now, we need to connect to the GitHub account. Click on Add New.
Authorize AWS to connect to your account. Click on Authorize AWS connector for GitHub.
A new window will open up. Under GitHub connection, enter in a connection name.
Once done, click on Install another to install the connector to your repository.
A new window will pop up. Select Only select repositories and choose the repo you created above. Click on Install.
Select the connector from the dropdown and click on Next.
On success, you will see the message as shown in the image below.
From the dropdown, select the connection you created above.
Select the repository and the branch which contains the code base.
Under the Deployment settings, select Automatic. Click on Next.
In Step 2, for configuring the build, we have two options. Either manually or with the help of a YAML configuration file. Select the runtime as Python 3.
Enter the build command, start command, and the port as shown in the image below. Once done, click on Next.
Another way is to just select Use a configuration file that will look for a app.yaml file in our code base. Click on Next.
In Step 3, you can configure the virtual CPUs and memory as per your requirements.
Click on Add environment variable if you need to add any for your configuration.
Expand Auto Scaling. The default configuration is selected by default. You can also go for a custom configuration for the same.
You can configure and alter the health check configurations as per your need.
Expand the Security sub-section and select a KMS key if you need encryption enabled.
You can also add tags to your service from the tags sub-section.
Finally in the last step, review all the configurations you configured.
Once done, scroll down to the bottom and click on Create and Deploy.
The service creation might take some time to be configured.
On success, you will see the message as shown in the image below.
At the bottom of the screen, click on Logs to see the various logs available for your service. You can even view them on CloudWatch by clicking on View in CloudWatch.
Click on Configuration to view the configuration settings.
Select the metrics section to view the various metric information provided for your service.
You can also create a custom domain for your application. Select the Custom domain tab and click on Add Domain.
A new modal will appear wherein you need to enter the domain name and click on Save.
Now, click on the Default domain link to check if the application has been deployed successfully.
You will be navigated to a page as shown in the image below which states that the application has been deployed successfully.
Now, for each new update in the code base, you need to redeploy the application. Click on Deploy on the service screen. It might take a few minutes for the deployment to take place.
On success, you will see the message as shown in the image below and now you will get to see the new updates on the same link.
Conclusion
In this blog, we saw how we can make use of the AWS App Runner service to deploy a scalable and secure web application within minutes. We first created a new repository on our GitHub account and then connected to the source code via the AWS App Runner Console by authorizing access to AWS. We then explored the AWS App Runner dashboard to have a look at its various features, benefits, use cases, etc. Then we created an App Runner service and finally, thereby following a 4-step process, we connected to the GitHub repo and deployed the source code in the repo which was then accessed using the default link.
We also saw how we can create custom domains for the application as well as how we can redeploy the application if certain code changes occur in the code base so that the changes are reflected on the application. We will discuss more use cases of AWS App Runner in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.
Meanwhile …
Keep Exploring -> Keep Learning -> Keep Mastering
This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.