Continuous Deployment using GitHub Actions and AWS EC2 — Part I: EC2 instance

Mansoor Khan
3 min readApr 27, 2023

--

Introduction

This is a multi-part article series that will guide you to deploy your app to EC2 instance using GitHub Actions. In this series, I will guide you how to:

  • Create an AWS EC2 instance
  • Configure a domain,
  • Create IAM user and service roles,
  • Configure AWS CodeDeploy agent, and
  • Configure GitHub Actions for seamless Continuous Deployment

Create an EC2 instance on AWS

Go to https://aws.amazon.com/ and click on Create an AWS account

Sign up with with your email

  • One you finish signing up, log in as the root user.
  • Click on the Services menu item on the top left and choose EC2 service
  • Click on Launch an instance link and fill the relevant details to create an instance.
  • Choose a name
  • Add an OS image for ex: Ubuntu version 22.04 LTS
  • Leave the instance type to t2.micro unless you want to go for a high-end specification
  • Create a key pair to login to your instance via SSH
  • Leave the rest of the settings as it is unless you want to customize it for better storage options etc.
  • Once you are done, click on Launch Instance to create a new EC2 instance.
  • From the AWS management console, browse to the instance page which shows all the details of your newly created instance.
  • Click on Connect button and go to the SSH Client tab which provides clear instructions on how to connect to your instance using SSH. For ex:
    ssh -i “<pem file name>” ubuntu@<ip address>.<region>.compute.amazonaws.com

If you haven’t created a key pair, you can go to https://<region code>.console.aws.amazon.com/ec2/home?region=<region code>#KeyPairs and click on Create key pair to create and download your key (.pem) file.

In this article you learned how to create a free tier AWS EC2 instance and validated SSH connection using .pem file.

In the next article of this series, I will explain you how to setup your domain configuration for routing your website traffic using Route 53 to AWS EC2.

Hope you found this article useful.

Stay tuned!

--

--