- An AWS account
- A Node.js application repository hosted on a version control system like GitHub or AWS CodeCommit
- 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:
- Initialized the directory for git, and the subsequent command to commit and push the directory contents to the repository using
git initgit add .git commitgit push
- 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:
- After pushing, the contents of the repo should look ike this:
-
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.
- 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.
- 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
- 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.
- This was troubleshooted and resolved after several attempts as shown in the following images









