Deploy a Shopify 3.0 App on AWS

Usama Masood
5 min readDec 21, 2022

--

In this article, we will look into deploying a Shopify 3.0 app on AWS using AWS services like ECR for docker image, and ECS for container and running the task for it.

I’m considering you have the following things to get started:

  • A Shopify App (obviously) 😅
  • An AWS account
  • Motivation (I badly need it)

Step 1:

Ready your Docker file and add environment variables, port, etc

Docker File

Step 2:

Log in to the AWS console and head to ECR(Elastic Container Registry) service.

ECR

Then create a repository by adding the Repository Name. You can edit other configurations but let’s leave them as it is.

Once created, click on the repository name to open up the details page and click View Push Commands from the upper right corner to see the commands list. Run those commands in terminal in project’s root directory one by one to extract the docker image and then upload it to the ECR repository. Commands looks like this

Once the docker image is successfully pushed, you’ll be able to see it on the repository details page.

Copy and save the image URI, we will need it later.

This is it for the ECR part.

Step 3:

Now let’s head to the ECS(Elastic Container Service) and select Amazon ECS Cluster

Now create a Cluster with template EC2 Linux + Networking

I’m going to select t2 micro (free tier eligible) for this tutorial, you can select one with your needs.
You can find more details about the instance types here

Also, it is good practice to create a key pair for SSH or use an existing one(if any).

Now for the networking, select the default VPC and subnet assigned to your account by default, and make sure to enable Auto Assign Public IP

Create an IAM role for the ECS instance or use an existing one if already created.

Once the cluster is created and you see all greens on the page, we are good to go for the next step.

Step 4:

ECS provides two ways to deploy your container i.e Tasks and Services. You can read more about it here

For this tutorial, we will use Tasks. So let’s go ahead and create a Task Definition

Select the EC2 type. (We can also use the FARGATE type which handles the underlying configurations itself)

Now enter the memory and CPU for the task.

Keep in mind that these values should be less than or equal to the values that the EC2 instance (you selected previously) can support.

Now add a container definition to connect the image we uploaded on ECR. Get that URI of the image that you copied earlier, and paste it in image field. Fill other fields as per requirements like memory, CPU, GPU, etc.

For the port mapping, enter container port (on which the app runs), and the host port (on which the docker container will run).

Make sure to turn on the logs to see if anything goes wrong.

After adding all the container details, you will be able to see it in the container definitions list.

Step 5:

Now we are in the endgame!!

Head back to the cluster and switch to the tasks tab

Click on Run new Task and select EC2 Launch Type. Select the Task Definition you just created with the latest revision and click on Run Task

Wait for the task to get in Running State and tadaaaa!! We’re done here!

Now you are going to need a domain and have to setup SSL but we are not going into that in this tutorial.

I hope this helps to get an app up and running.

If you have any comments or improvement ideas, feel free to comment or contact me.

If you liked this post, please follow me. I would be very grateful ;)

--

--

Responses (1)