Skip to content
This repository was archived by the owner on Jul 30, 2022. It is now read-only.

Latest commit

 

History

History
123 lines (89 loc) · 4.72 KB

File metadata and controls

123 lines (89 loc) · 4.72 KB

Deployment

Creating an AWS Account

Create IAM Roles

Create and Launch an EC2 Instance

  • Choose Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type as your machine image
  • Choose t2.micro (Free tier eligible) for instance type
  • Under Configure Instance Details, select the previously created IAM Role.
  • Under Configure Security Group, Allow incoming access to:
Type Port Range Description.
SSH 22 Port for SSH into server
HTTP 80 Port for HTTP requests to web server
HTTPS 443 Port for HTTPS requests to web server
Custom TCP 5000 Port for API
  • Finally, launch the instance and create a new key pair and store it in a secure and accessible location. (This will generate a .pem key which is used for SSH)

Install Packages in EC2 Instance

After ssh, run the following commands:

Update package management tool

  $ sudo yum update

Install CodeDeploy Agent (locate your region first)

  $ sudo yum install -y ruby
  $ sudo yum install wget
  $ wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
  $ chmod +x ./install
  $ sudo ./install auto
  $ sudo systemctl start codedeploy-agent

Install nginx

  $ sudo yum install nginx

Install Nodejs

  $ sudo yum install nodejs

Install dotnet environment

run the following commands to add the Microsoft package signing key to your list of trusted keys and add the Microsoft package repository.

  $ sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

To install the .NET SDK, run the following command:

  $ sudo yum install dotnet-sdk-6.0

Install pm2

  $ sudo npm install -g pm2

Set up RDS database

  • Choose Standard create for creation method

  • Choose PostgreSQL for Engine type and 12.9-R1 for Version under Engine options

  • Select Free tier for template

  • Create and store username and password credentials (will be used in connection string)

  • Turn Public access off and choose the same virtual private cloud the EC2 instance is on

  • For authentication options, select Password authentication.

  • To allow communication between API and database:

    • Go to EC2 console and under security groups add the database's and EC2's security groups to eachothers inbound and outbound rules.
  • To add connection string to EC2 environment,

    1. SSH into EC2 server
    2. cd into the api folder and create appsettings.Production.json file with the connection string using vim.

Configure CodeDeploy

Configure CodePipeline

  • Create new pipeline and select new service role
  • Select Github (Version 2) for source provider and add the github repository.
  • Choose Start the pipeline on source code change for Change detection options.
  • Choose CodePipeline default for Output artifact format.
  • Choose AWS CodeBuild for Build provider
    • Create a new build project
    • Choose Managed image for Environment image and Amazon Linux 2 for Operating System.
    • Select Standard Runtime and aws/codebuild/amazonlinux2-x86_64-standard:3.0 for image.
    • Choose aws/codebuild/amazonlinux2-x86_64-standard:3.0-21.10.15 for image version and Linux for Environment type.
    • Select New service role for Service role.
    • Create and add buildspec.yml to github repo and put its path for the Build specifications name.
    • Continue to CodePipeline
  • For Deploy provider, select AWS CodeDeploy and choose the previously created application and deployment group.