{"id":20371550,"url":"https://github.com/atulkamble/samplewebapp","last_synced_at":"2026-03-08T01:10:53.882Z","repository":{"id":256125392,"uuid":"854385110","full_name":"atulkamble/SampleWebApp","owner":"atulkamble","description":"A simple Node.js web server application demonstrating the use of AWS CodeCommit, CodeBuild, and CodeDeploy for continuous integration and continuous deployment (CI/CD) on an EC2 instance.","archived":false,"fork":false,"pushed_at":"2024-09-09T05:41:13.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T15:42:08.681Z","etag":null,"topics":["cicd","codebuild","codecommit","codedeploy","continuous-delivery","continuous-integration","devops","ec2"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atulkamble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T04:35:14.000Z","updated_at":"2024-09-09T05:41:16.000Z","dependencies_parsed_at":"2024-09-09T05:52:47.814Z","dependency_job_id":"d0177f1e-a34c-4824-bbfa-b8323e900cef","html_url":"https://github.com/atulkamble/SampleWebApp","commit_stats":null,"previous_names":["atulkamble/samplewebapp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atulkamble/SampleWebApp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2FSampleWebApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2FSampleWebApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2FSampleWebApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2FSampleWebApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulkamble","download_url":"https://codeload.github.com/atulkamble/SampleWebApp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2FSampleWebApp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30240440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"ssl_error","status_checked_at":"2026-03-08T00:55:48.608Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","codebuild","codecommit","codedeploy","continuous-delivery","continuous-integration","devops","ec2"],"created_at":"2024-11-15T01:08:29.951Z","updated_at":"2026-03-08T01:10:53.862Z","avatar_url":"https://github.com/atulkamble.png","language":null,"readme":"# SampleWebApp\nA simple Node.js web server application demonstrating the use of AWS CodeCommit, CodeBuild, and CodeDeploy for continuous integration and continuous deployment (CI/CD) on an EC2 instance.\n\n### **Tags**:\n- Node.js\n- AWS CodeCommit\n- AWS CodeBuild\n- AWS CodeDeploy\n- CI/CD Pipeline\n- EC2 Deployment\n- DevOps\n\n```\ncd Downloads\nssh -i \"terraformkey.pem\" ec2-user@ec2-54-84-239-38.compute-1.amazonaws.com\n```\n\n### Prerequisites:\n1. **AWS CLI** installed and configured. [Download and install AWS CLI](https://aws.amazon.com/cli/)\n2. **IAM Role** with necessary permissions (CodeCommit, CodeBuild, CodeDeploy, EC2 access).\n3. **EC2 Instance** running Amazon Linux 2 or another supported platform.\n4. **AWS CodeDeploy agent** installed on the EC2 instance.\n// Install the CodeDeploy agent for Amazon Linux or RHEL\n```\nsudo yum update -y\nsudo yum install ruby -y\nsudo yum install wget -y\nwget https://aws-codedeploy-us-east-2.s3.us-east-2.amazonaws.com/latest/install\nchmod +x ./install\nsudo ./install auto\nsystemctl status codedeploy-agent\nsystemctl start codedeploy-agent\n```\n---\n\n### Step 1: Create a CodeCommit Repository\n\n```\nsudo yum install git -y\ngit --version\n```\n1. **Create Repository in CodeCommit:**\n   - Open the AWS Management Console and go to **CodeCommit**.\n   - Create a new repository named `SampleWebApp`.\n   \n2. **Clone the Repository Locally:**\n   ```bash\n   git clone https://git-codecommit.\u003cregion\u003e.amazonaws.com/v1/repos/SampleWebApp\n   cd SampleWebApp\n   ```\n\n### Step 2: Create a Simple Node.js Application\n```\nsudo yum install npm -y\nnpm --version\n```\n```\nmkdir sample-web-app\ncd sample-web-app\n```\n1. **Initialize a Node.js project:**\n   ```bash\n   npm init -y\n   ```\n\n2. **Install Express.js:**\n   ```bash\n   npm install express\n   ```\n\n3. **Create `app.js` file:**\n   ```javascript\n   const express = require('express');\n   const app = express();\n\n   app.get('/', (req, res) =\u003e {\n       res.send('Hello from CodeDeploy!');\n   });\n\n   const port = process.env.PORT || 3000;\n   app.listen(port, () =\u003e {\n       console.log(`App is running on port ${port}`);\n   });\n   ```\n\n4. **Create a `package.json` script to run the application:**\n   Add this to your `package.json`:\n   ```json\n   \"scripts\": {\n       \"start\": \"node app.js\"\n   }\n   ```\n\n### Step 3: Create a BuildSpec File for CodeBuild\n\n1. **Create `buildspec.yml`** in the root of your repository:\n\n   ```\n   touch buildspec.yml\n   sudo nano buildspec.yml\n   ```\n   ```yaml\n   version: 0.2\n\n   phases:\n     install:\n       commands:\n         - echo Installing dependencies...\n         - npm install\n     build:\n       commands:\n         - echo Build started on `date`\n         - npm run start\n   ```\n\n### Step 4: Create an AppSpec File for CodeDeploy\n\n1. **Create a `appspec.yml`** in the root of your repository:\n\n   ```\n   touch appspec.yml\n   sudo nano appspec.yml\n   ```\n   ```yaml\n   version: 0.0\n   os: linux\n   files:\n     - source: /\n       destination: /home/ec2-user/sample-web-app\n\n   hooks:\n     AfterInstall:\n       - location: scripts/install_dependencies.sh\n         timeout: 300\n         runas: ec2-user\n     ApplicationStart:\n       - location: scripts/start_server.sh\n         timeout: 300\n         runas: ec2-user\n   ```\n\n### Step 5: Create Shell Scripts for Deployment\n\n1. **Create a directory `scripts/`** and add the following files:\n\n   **`install_dependencies.sh`**\n   ```\n   touch install_dependencies.sh\n   sudo nano install_dependencies.sh\n   ```\n   ```bash\n   #!/bin/bash\n   cd /home/ec2-user/sample-web-app\n   npm install\n   ```\n\n   **`start_server.sh`**\n   ```\n   touch start_server.sh\n   sudo nano start_server.sh\n   ```\n   ```bash\n   #!/bin/bash\n   cd /home/ec2-user/sample-web-app\n   npm start \u0026\n   ```\n\n3. **Make the scripts executable:**\n   ```bash\n   chmod +x scripts/*.sh\n   ```\n\n### Step 6: Push the Code to CodeCommit\n\n1. **Add, commit, and push the code to CodeCommit:**\n   ```bash\n   git add .\n   git commit -m \"Initial commit\"\n   git push origin main\n   ```\n\n### Step 7: Set Up AWS CodeBuild\n\n1. **Create a CodeBuild Project:**\n   - Go to **AWS CodeBuild** in the console.\n   - Create a new build project, selecting the **CodeCommit** repository and configuring the build environment for **Node.js**.\n\n2. **Choose BuildSpec:**\n   - Choose the `buildspec.yml` file for the build commands.\n\n### Step 8: Set Up AWS CodeDeploy\n\n1. **Create an Application in CodeDeploy:**\n   - Go to **AWS CodeDeploy** and create a new application.\n   - Create a **deployment group** for your EC2 instances with the appropriate IAM role.\n\n2. **Configure EC2 Instances:**\n   Ensure the **CodeDeploy agent** is installed on your EC2 instance:\n   ```bash\n   sudo yum update -y\n   sudo yum install -y ruby\n   cd /home/ec2-user/\n   wget https://bucket-name.s3.region.amazonaws.com/latest/install\n   chmod +x ./install\n   sudo ./install auto\n   sudo service codedeploy-agent start\n   ```\n\n### Step 9: Set Up a Deployment Pipeline\n\n1. **Create a Pipeline:**\n   - Go to **AWS CodePipeline** and create a new pipeline.\n   - Set **CodeCommit** as the source.\n   - Set **CodeBuild** as the build stage.\n   - Set **CodeDeploy** as the deploy stage.\n\n2. **Deploy the Application:**\n   - Push new changes to trigger the pipeline.\n\n---\n\n### Testing and Conclusion\n\nAfter pushing your code and triggering the pipeline, CodeCommit will store the code, CodeBuild will build the application, and CodeDeploy will deploy it to your EC2 instance. You can visit your EC2 instance's public IP to see the running application.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fsamplewebapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkamble%2Fsamplewebapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fsamplewebapp/lists"}