Blog
Projects
Linkedin
Contact

How to Deploy Applications Using CI/CD with CircleCI on AWS and Vercel

May 10, 2025

With the growing need for efficient and reliable software delivery, setting up an automated deployment pipeline has become a fundamental practice. In this article, we’ll integrate CircleCI to automate deployments to both Vercel and AWS EC2, so that every change pushed to your repository is automatically built and deployed with minimal manual intervention. You'll learn how to:
Let's get started!

1. Cirlce CI

For this automation, we will use Circleci, a robust continuous integration tool and easily integrated with Github repositories.

Requirements

Connecting Github to Circleci

Circle CI log-in
After logging in, you will be redirected to the CircleCI dashboard. There, you will need to create an 'Organization,' and once that's done, you can proceed to create a project. Follow the steps below to complete the process:

Setting up a project

Circle CI Dashboard
After clicking on the Set up a project tab, you will be redirected to a page where you can select the repository you want to connect to CircleCI. Choose the desired repository and click on the Set Up Project
Circle CI configuration
After selecting the option, you will be redirected to a page where you can view the pipeline that has been created. This pipeline represents a basic configuration for building and deploying your application. You can customize it to suit your specific needs.
Circle CI All pipelines

Creating your own pipeline

To create your own pipeline, go to the project settings and navigate to the pipeline tab.
Circle CI add new pipelines
Circle CI adding a pipeline

Creating your trigger

To create your trigger, go to the project settings and navigate to the triggers tab.
Circle CI add new trigger
Here you can select many types of triggers, but for this tutorial we will select the Github App to create a trigger that will be executed when a pull request is created in to the main branch.
Circle CI adding a Trigger

Creating environment variables

To create environment variables, go to the project settings and navigate to the environment variables tab.
Circle CI environment variables
Here you can create environment variables that will be used in your pipeline. You can create as many environment variables as you want.
To add an environment variable, click on the Add Environment Variable button and enter the name and value of the variable.
Circle CI add environment variables

Creating SSH keys

To create SSH keys, go to the project settings and navigate to the SSH keys tab.
Circle CI SSH keys
Here you can create SSH keys that will be used in your pipeline. You can create as many SSH keys as you want.
To add an SSH key, click on the Add SSH Key button and enter the name and value of the key.
Circle CI add SSH keys

2. Vercel

To deploy your application to Vercel, you will need to create a Vercel account and connect it to your Github account. Once you have done this, you can generate a token that will be used to authenticate your application with Vercel. Follow the steps below to complete the process:

Requirements

Generating a vercel token

To generate a Vercel token, go to the Vercel dashboard and navigate to the account settings. There, you will find an option to generate a new token. Click on it and follow the instructions to create a new token. Once you have generated the token, copy it and save it in a secure place.
Vercel Account Settings

Creating environment variables in your Circle CI project

Next, let's define the environment variables required to deploy to Vercel, we need to create some environment variables in our Circle CI project to be able to deploy our application to Vercel and AWS EC2.
To this project, we will need to create the following environment variables:
The VERCEL_PROJECT_NAME variable is the name of your project in Vercel. You can find it in the Vercel dashboard. The VERCEL_TOKEN variable is the token that you generated in the previous step. You can find it in the Vercel dashboard as well.

Seting up your config file

To set up your config file, you can use the following example:
.cirlceci/config.yml

version: 2.1
jobs:
  deploy-vercel:
    docker:
      - image: cimg/node:lts
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm install --force
      - run:
          name: Install Vercel CLI
          command: npm install -g vercel
      - run:
          name: Link Vercel project
          command: vercel link --project $VERCEL_PROJECT_NAME --token $VERCEL_TOKEN --yes
      - run:
          name: Deploy to Vercel
          command: vercel --prod --token $VERCEL_TOKEN --yes --no-wait
      
    workflows: 
      build-and-deploy: 
        jobs: 
          - deploy-vercel

3. AWS EC2

To deploy your application to AWS EC2, you will need to create an AWS account and launch an EC2 instance. Once you have done this, you can generate a key pair that will be used to authenticate your application with AWS. Follow the steps below to complete the process:

Requirements

Creating an SSH key in your Cirlce CI project

As we could see in the previous steps, we need to create an SSH key in our Circle CI project to be able to deploy our application to AWS EC2.

Creating an Github Token

To create a Github token, go to the Github account settings and navigate to the developer settings. There, you will find an option to generate a new token. Click on it and follow the instructions to create a new token. Once you have generated the token, copy it and save it in a secure place because we are going to use it later on the project.
Github Token

Creating environment variables in your Circle CI project

As we could see in the previous steps, we need to create some environment variables in our Circle CI project to be able to deploy our application to AWS EC2.
To this project, we will need to create the following environment variables:
The SSH_USER variable is the user that you will use to connect to your EC2 instance. The SSH_IP variable is the IP address of your EC2 instance. The GITHUB_USER variable is your Github username. The GITHUB_TOKEN variable is the token that you generated in the previous step. You can find it in the Github dashboard as well.

Seting up your config file

To set up your config file, you can use the following example:
.cirlceci/config.yml

version: 2.1

jobs:
  deploy:
    docker:
      - image: cimg/base:stable
    steps:
      - add_ssh_keys:
          fingerprints:
            - "SHA256...." # Replace with your SSH key fingerprint
      - run:
          name: Deploy to EC2 via SSH
          command: |
            ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_IP "
              cd flyup-api &&
              git remote set-url origin https://$GITHUB_USER:$GITHUB_TOKEN@github.com/....git && # Replace with your repository URL
              git pull &&
              sudo docker compose down &&
              sudo docker compose up -d --build
            "

workflows:
  deploy_workflow:
    jobs:
      - deploy
It's important to note that the code after you connect your Github Account in the following line:
.cirlceci/config.yml

              git remote set-url origin https://$GITHUB_USER:$GITHUB_TOKEN@github.com/....git && # Replace with your repository URL
              git pull &&
                
Is the code that will be executed in your EC2 instance. In this example, we are using docker compose to deploy our application. You can replace this code with the code that you use to deploy your application.

Closing Thoughts

Setting up a CI/CD pipeline using CircleCI to deploy on both Vercel and AWS EC2 may seem complex at first, but once the foundation is in place, it significantly enhances your development workflow.
Automating deployments reduces human error, saves time, and ensures consistent delivery. Whether you're deploying a static site on Vercel or scaling applications with AWS EC2, this approach gives you flexibility and control.
If you found this guide helpful, feel free to share it and if you have any questions or comments just contact me. Your journey to streamlining your development and deployment workflow has just begun! 🚀
BlogProjectsGithubLinkedin
Built with Next.js, Tailwind and Vercel
Coded by me (Bruno Werner :P)