Skip to content

Y2O-Dev/aws-cicd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Continuous Integration (ci) Project Using Node.js App

Prerequisites:

  • An AWS account
  • A Node.js application repository hosted on a version control system like GitHub or AWS CodeCommit

Step 1: Preparing the Source Code:

  • Make a directory named aws-cicd and CD into it using the command:

mkdir aws-cicd && cd $_

  • create an index.js file that will contain the javascript code
  • Also create an index.html file that'll containt the HTML content
  • Create a buildspec.yml file which contains instruction for the pipeline
  • Create a Dockerfile that contains the instructions to build docker image
  • The above files were created using

code index.js index.html buildspec.yml Dockerfile

  • Installs both nodejs and NPM:

sudo apt install nodejs -y

  • NPM is a package manager for Node and it is used to install Node modules & packages and to manage dependency conflicts.
  • The contents of the directory as showwn in the below diagram:

files

  • Initialized the directory for git, and the subsequent command to commit and push the directory contents to the repository using

git init git add . git commit git push


Step 2: Set up AWS CodeCommit Repository:`

  • On the AWS console, open the CodeCommit service
  • Navigate to the "Repositories" and click on "Create Repository"
  • Give it a desired name and description. In my case, I name my repo Trios-2
  • Click on create to create the repo and you'll be returned to the repository page with your created repo as shown below image:

codecommit-repo

  • After pushing, the contents of the repo should look ike this:

repo-contents


Step 3: Set up an AWS CodeBuild Project:

  • On the AWS Management Console, open the CodeBuild service.

  • Click on "Create build project" and provide a name and description for the project.

  • Under "Source provider," select the version control system where your Node.js application repository is hosted and in this case, CodeCommit.

  • Connect to your repository and select the appropriate branch (Master in my case) as shown in the accompany diagram.

creating-build-contd

Configure the build settings:

  • Environment: Choose the environment image that suits your application. Although, no variable specify for in this project.
  • Buildspec: Create a buildspec.yml file in your repository that defines the build steps and environment.
  • Artifacts: Configure the output location for build artifacts.
  • Adjust any additional settings, such as VPC configuration or build timeouts. In my own case, There's no need configuring this.
  • Save the project configuration.

build-project


Step 3: Setting up the CodePipeline:

  • Go to the AWS Management Console and search for "CodePipeline".
  • Click on "Create pipeline" and follow these steps:
  • Provide a pipeline name.
  • For "Source provider," select "AWS CodeCommit".
  • Select the repository and branch you want to use.
  • For "Build provider," choose "AWS CodeBuild".
  • Configure the build provider with the appropriate settings (e.g., operating system, runtime).
  • For "Deployment provider," it is skipped for now as it will be done in the subsequent project
  • Attach AmazonEC2ContainerRegistryFullAccess as a permissions policy to the pipeline. This will grant the pipeline permission to the container registry

policy

  • AWS CodeBuild will automatically pull the latest code changes, execute the build steps defined in the buildspec.yml file, and produce build artifacts.
  • The pipeline initially print an error messages below, and subsequently got interrupted.

pipeline-error

  • This was troubleshooted and resolved after several attempts as shown in the following images

build-hx-status

build-success

ci-pipeline


END

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors