AWS App Runner
Tags: apprunner, aws, ecs, ecr
Published: 2024-01-19 23:39:17


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pua9hche30zeeho8cd9.png)


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": "*"
        }
    ]
}

```
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yz17tr7w9ostrodlu58b.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjtszsu8im2e8nxul8kj.png)

Step 2:
Source  can be chosen from two options

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tag24ggllp7karls4q5d.png)


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf2zlvhtrnmepcf9rwbx.png)

Then select the image

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pfft70kdf1uybxgoq28.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jw6tjh74rejhw24ki0b.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhol5avipotqy4kxki38.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6brb0n7fl67szpay3g89.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9s5d977nbdzdbkxeevp.png)

Step 6 : Review and Create


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90o3ixol2dz38npe0kzg.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbt35cow4k91lz7jvcbq.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/siifkrjfw3langwvj3di.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sj5fbhdefed04c6srfjo.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5ms6lscur6s57tdau5b.png)

Step 7: Deployment in progress


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40ghry8fyjsyanarzv0n.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4iq4uamx9i4i38l728ew.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvnffwaypmg5fe5rka10.png)

Step 10 : Deleting the App Runner - service

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eh2e1qhtjk7k63k6aq2g.png)

Confirm the deletion by typing delete and then click on Delete 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o95lmpo4ore38fr39hor.png)

Step 11 : Deleting in progress


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsr7ir7vhko7hd2tuvnv.png)

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](https://www.linkedin.com/in/srinivasuluparanduru/)