successfully deployed apprunner service on aws

2 Ways How To Deploy Websites With AWS AppRunner


AWS offers so many amazing managed services. I happen to stumble upon the AWS Apprunner recently when I was looking up the list of choice that can deploy web applications with little know-how. It is a little similar to the Elastic Beanstalk in function, however, the difference lie in the part where Apprunner can run automatic deploy the web application directly from Github. You do not need to zip the source code and upload it like what is required when using Elastic Beanstalk. Although an exception is manually using GitHub to deploy to Elastic Beanstalk

One other difference is the SSL certificate that comes with the AWS Apprunner service URL by default, while for AWS Elastic Beanstalk and EC2 deployments you will need to manually configure SSL with the LoadBalancer HTTPs protocol, or redirect with an domain provider DNS certificate.

what is AWS app runner

Like I mentioned earlier, AWS App Runner is a fully managed service that makes it easy for you to quickly build, deploy, and manage containerized web applications and APIs at scale and with no prior infrastructure experience required. Starting with the source code or a container image, App Runner will automatically build, scale, and secure the web application in the AWS Cloud.

And so, we will deploy a BootStrapped NodeJS application using the AWS Apprunner service.

source code source

Before we begin, let me mention I do not own the source code used in this demo. It is a free template from (Github repo). Thanks to StartBootstrap for the good job.

Also, using AWS Apprunner to deploy web application with docker requires a Dockerfile. I created one. You will find the link to the GitHub repository later in this demo.

That been said, let’s move into the business of the day.

create the apprunner service

Search for Apprunner from the AWS Console search bar. Click on Create Service

Create the apprunner service
deploy from GITHUB source code repository

On the next screen, you will be asked to select the Source for AWS Apprunner to deploy your web application. For now, we will use Source Code Repository. And there you will connect your GitHub repository to AWS Apprunner a similar process to deploying Elastic Beanstalk from GitHub.

Select Source Code Repository, click on the Add New.

select source code to connect github with apprunner service

In the next screen, enter a Connection Name, then click the Install Another (for new github connections). A pop up window will open for you to select your GitHub organizations. Select any of the organization and then the repository containing the source code of your web application.

enter name for github connect

Once you are done with the configuring the repository where AWS Apprunner will deploy from, you will be returned to the Apprunner Connection window with the location automatically updated. Click Next.

Select gihub organization for apprunner connection to deploy web application

You will return to the AWS Apprunner Source window. Select the Organization, the Repository and the Branch if it not automatically populated.

Scroll down under deployment settings, select Automatic. This will make AWS Apprunner automatically pick up any changes from GitHub repository and deploy the web application.

Click Next.

Use the Automatic option for apprunner

In the Build Settings, select NodeJS 16 (16 is the version). Thereafter, enter the npm install and npm start, and 3000 (your application port) in the Build command, Start command, and Port respectively. This will ensure AWS Apprunner compile, build and start the web application we deploy on the correct port number.

If you choose to Use a Configuration File, check this repository for sample yml file

Click Next.

Configure the runtime for web application and port

In the Service Settings window, enter a Service Name to identify the web application Apprunner will deploy. However, if your web application uses some environment variables, you can specify them in the Environmental Variables field in the Key-Value format.

Enter the service name for the web application

Once done, click on Next.

Click Next in apprunner settings

On the review page, review all the configuration especially the port, build and, start command. Then Click Create & Deploy.

Click the create and deploy for aws code deploy

It takes about 10 minutes for AWS Apprunner service to configure your environment and deploy the web application. Therefore, exercise a little patient when it is deploying.

After Apprunner deploy the web application, you will get the green ribbon notification, and the URL to access the Apprunner deployed web application.

You can then choose to use a custom domain to serve your application with secure SSL certificate.

URL of the web application apprunner deploy
access the application using the apprunner url

Paste the URL from Apprunner to view you deployed website. Now you can easily make changes in your application source code, push it to GitHub and AWS Apprunner will automatically run the process to deploy your web application.

using ECR Docker Registry WITH APP RUNNER

We will see how to configure AWS Apprunner to deploy the same web application using docker image. Already created AWS container registry is a prerequisite to this option. Follow this tutorial to see how to create an AWS Container Registry You also need to create a Dockerfile in the root of your project.

Clone the project repository with Dockerfile here.

Navigate under the source, select the Container Registry option. Choose the Amazon ECR and paste in the URI of the container registry. Alternatively, click the Browse and select the repository and the image tag of the repository.

Under Deployment Settings, select Automatic, and Create New Service Role under the ECR access role. Click Next. Follow this demo to create and use custom IAM service role.

Select the container registry and the ECR. Create service role.

Under the Service Settings, enter a name and enter the port number. The port number should be the same as the port exposed in your Dockerfile

configure service in apprunner

Click on the Next to review you application setting, then click Create & Deploy.

Create and deploy application

It takes a couple of minutes for Apprunner to deploy your web application with docker. Once done, grab the URL and access you application from the browser. You can also use a custom domain and SSL certificate with this URL.

apprunner successfully deploy the web application with docker

You will agree with me that AWS Apprunner service is one of the best service to use to deploy web application. I recommend you practice over again until you are comfortable with it.

Also, I strongly advise you delete the application once you are done with the demo if you are not using Apprunner for production deployment yet. Leaving the service running could attract some billing to your account.

Thanks for coming by, checkout out how to use Elastic Beanstalk to deploy your Next application. I also have a tutorial on how to deploy a dotnet API application with docker.

  1. ERROR: Application not found when accessed from the web browser
    SOLUTION: Check that the application port configured n the Apprunner service is the same. Also check that the environment variables is correctly entered during configuration.
    NB: You may need to redeploy the who application from the beginning with Apprunner service






Leave a Reply

Your email address will not be published. Required fields are marked *