DEV Community

Srinivasulu Paranduru for AWS Community Builders

Posted on • Updated on

AWS App Runner

AWS App Runner : AWS App Runner is a fully managed service that makes it easy for developers to deploy from source code or container image directly to a scalable and secure web application.

Image description

Benefits :

  • Easy to use
  • Saves time
  • Scales with traffic

Features:

  • Automatic Deployments
  • Logs and metrics
  • Load Balancing
  • Auto Scaling
  • Secure by design

Use cases:

  • Frontend and backend web applications
  • Microservices and APIs
  • Rapid production deployments

Pre-requisties for AWS APP Runner :

Task :Create Image and Push to ECR Repository
Launch EC2 instance - Amazon Linux 2 AMI, t2.micro
Connect to instance using EC2 Instance Connect

Run the following commands on EC2:

sudo su
yum update
yum install docker
systemctl enable docker.service
systemctl start docker.service
docker pull nginx
docker images

Create an IAM role ECR_Role and attach the policy

{
    "Version": "2012-10-17",
    "Id": "ECRPolicy",
    "Statement": [
        {
            "Sid": "AllowAll",
            "Effect": "Allow",
            "Action": "ecr:*",
            "Resource": "*"
        }
    ]
}

Enter fullscreen mode Exit fullscreen mode

1.Attach role - ECR_Role to EC2 instance and then run the following commands
2.Create ECR Repository
aws ecr create-repository --repository-name nginx --region eu-west-1

Image description

3.Tag the image and which we created earlier then replace ACCOUNT_Number with your account number
docker tag nginx:latest ACCOUNT_Number.dkr.ecr.eu-west-1.amazonaws.com/nginx:latest
4.Authenticate ECR login, replace ACCOUNT_Number with your account number.
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin ACCOUNT_Number.dkr.ecr.eu-west-1.amazonaws.com/nginx
5.Push the image to ecr and replace ACCOUNT_Number with your account number.
docker push ACCOUNT_Number.dkr.ecr.eu-west-1.amazonaws.com/nginx:latest

Note : From the above points 3,4 and 5, i have used the region ireland : eu-west-1 and change based on your preference.

Step by Step Approach for AWS App Runner creation

Step 1 :

Image description

Step 2:
Source can be chosen from two options

  • Container Registry (selected this option for the demo)
  • Source Code Repository

Image description

Step 3:
Select Container image URI by clicking on the Browse button

Image description

Then select the image

Image description

Image description

Step 4: Select Deployment Trigger

  • Manual / Automatic
  • ECR Access Role -> Select create new service role -> Role with name AppRunnerECRAccessRole will be created Then click on next Image description

Step 5: Configure Service
Step 5.1: Give the service name as nginx-service and port as 80

Image description

Step 5.2 : Keep the remaining settings as it is and then click Next

Image description

Step 6 : Review and Create

Image description

Image description

Image description

Image description

Image description

Step 7: Deployment in progress

Image description

Step 8: Select Default domain as per the below screenshot - https://53zz55dm4a.eu-west-1.awsapprunner.com/

Image description

step 9 : Render the url - https://53zz55dm4a.eu-west-1.awsapprunner.com/

Image description

Step 10 : Deleting the App Runner - service

Image description

Confirm the deletion by typing delete and then click on Delete

Image description

Step 11 : Deleting in progress

Image description

Step 12 : Also delete EC2 created in the pre-requisite tasks.

Conclusion:

  1. Created Image and Push to ECR Repository
  2. Created APP Runner and used the image created
  3. Rendered the APP Runner URL generated
  4. Destroyed APP Runner service

๐Ÿ’ฌ If you enjoyed reading this blog post and found it informative, please take a moment to share your thoughts by leaving a review and liking it ๐Ÿ˜€ and follow me in linkedin

Top comments (0)