-
To set up the Node.js web application, use the command:
npx create-react-app my-node-appThis command initializes a new React application in a directory named "my-node-app."
-
Validate the app's local functionality by running the following commands:
-
To start the development server:
npm startThis command launches the development server, which enable viewing the app in a local environment.
-
To build the app for production:
npm run buildRunning this command generates a production-ready build of the app that can be deployed.
-
-
Install the AWS Command Line Interface (CLI) on the Ubuntu local system using the package manager:
-
Open a terminal.
-
Run the following command to install the AWS CLI:
sudo apt install awscli -
Verify the installation by checking the version:
aws --version
-
-
Configure the AWS CLI by running:
aws configureThis command prompts for the AWS access key, secret key, default region, and output format.
- Set up Git and push the code to GitHub as follows:
-
Initialize Git repository:
git init -
Add the files to the staging area:
git add . -
Commit the changes:
git commit -m "Initial commit" -
Connect the local repository to the GitHub repository:
git remote add origin https://github.com/the-username/repo-name.git -
Push the code to GitHub:
git push -u origin master
-
-
Use the AWS Management Console to create an S3 bucket:
- Log in to the console and navigate to Amazon S3.
- Click the "Create bucket" button.
- Provide a unique bucket name and choose region and other settings as needed.
-
Create a CloudFront distribution through the AWS Management Console:
- Navigate to Amazon CloudFront.
- Click the "Create Distribution" button.
- Select "Web" as the delivery method.
- Specify the created S3 bucket as the origin domain name.
- Configure other settings and distribution options as required.
-
Set up an AWS CodePipeline to automate the deployment process:
-
Access the AWS Management Console.
-
Navigate to AWS CodePipeline.
-
Click the "Create pipeline" button.
-
Configure the source stage to connect to the GitHub repository.
-
Configure the build stage to use AWS CodeBuild:
- Specify the buildspec file.
- Set the runtime version to Node.js 18.
-
Configure the deploy stage to use AWS CodeDeploy:
- Specify the "BB" S3 bucket as the deployment destination.
- Enter the CloudFront distribution ID to trigger cache invalidation.
-
Configure IAM role to grant the build access permission to s3, Cloud front.
-
-
Once the AWS CodePipeline is configured, it will automatically trigger upon changes in the GitHub repository.
-
The pipeline will execute the following phases:
- Source: Clone the repository and fetch the source code.
- Build: Use the buildspec file to run the build process.
- Deploy: Deploy the build artifacts to the "BB" S3 bucket.
- CloudFront Invalidation: Invalidate CloudFront cache to ensure fresh content.







