Deploying Code on GitHub and EC2 Using AWS CodeDeploy (1)

April 22, 2021

Easy deployment using CI / CD tools helps developers and engineers focus on developing and testing their software. Tools like GitHub Actions have become quite popular, and Amazon also has developed and maintained relevant tools for AWS customers.

Using AWS CodeDeploy and CodePipeline, and GitHub, you can push your code to your GitHub repo and automatically deploy that to EC2 instances. This article includes a few references that I have used and some notes.


Table of Contents

  • Deploying Node.js app on EC2
  • Configuring CodeDeploy agent on an EC2 instance
  • Setting up CodeDeploy and CodePipeline (with S3)

Deploying Node.js app on EC2


Configuring CodeDeploy agent on an EC2 instance

  • After installing node, nvm, and others, you need to install codedeploy-agent to create the pipeline.

    • Please note about the version issue mentioned above if you are using ubuntu.

Creating GitHub Repo

  • In the repo, you should include appspec.yml:

    version: 0.0
    os: linux
    files:
    - source: ./index.js
    destination: /home/ubuntu/your-app-name
    - source: ./package.json
    destination: /home/ubuntu/your-app-name
    permissions:
    - object: /home/ubuntu
    owner: ubuntu
    group: ubuntu
    type:
      - directory
      - file
    

Setting up CodeDeploy and CodePipeline (with S3)