Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nodejs and Terraform Project

Hands-on

Part-01

=> Running without Dockerfile

  1. npm install
  2. node code.js

=> Running using Dockerfile

-> Build docker Image using Dockerfile

  1. docker build -t http-project:0.0.1 . image

-> Run docker Image in iteractive terminal mode

  1. docker run -it -p 3000:3000 --name http-container http-project:0.0.1 image

    To run in detached mode run use flag -d.

Part-02

  1. First use terraform init command to Initialise and download our resource we mentioned in main.tf file image

  2. Following that use terraform validate command -> This will find any syntax error or any variable we're missing out referring to and etc. image

  3. Now use terraform plan command, this will show the plan also throw error if you haven't exposed the variables. It will look something like this. In our case. image

  4. Finally, use terraform --auto-approve command and let the terraform do it's magic. image

When we go to our http://publicIP:3000/list-bucket-content. We will be seeing image

  1. Destroy the infrastructure we provisioned using command terraform destroy --auto-approve image

Assumptions:

  1. S3 Bucket Unblocking access for account and bucket(our bucket. Named "list-bucket-content)

Part - 1

File Structure

image

  • Please refer code.js file inside the Part-1 directory to maintain the flow of understanding the project
  • Response you'll get once you run npm install -> node code.js command image

Part - 2

Assumptions

  • Create Dockerfile. So that we will not have to face the issue "It works on my machine."
  • Use AWS Secrets Manager to store the secrets and create required Role and attach a Policy to it. Follow least privilege best practice.
  • Create an EC2 Instance and deploy on it.
  • Use default VPC, and create a Security Group with required ports to expose.

Understanding Part-2

  • Refer to main.tf file inside the Part-2 directory while understanding it you'll have to refer to variables.tf and userdata.sh
  • I have made a video of 18 minutes and 58 seconds. I have attached it in the end of the this README file go through it for better understanding.
  • Then output.tf -> Once, the infrastructure is provisioned, Terraform will show us the value of these parameters.

S3 Bucket and API Response

  • The following API Response is coming from http://:3000/list-bucket-content image

Yeah so that's all I can recollect about the project for now, will edit this file if something comes up in my mind.

Here's the drive link to the video: https://drive.google.com/file/d/1uAVb9GIHaHHw-PFhbLSOok189CddQuoe/view?usp=sharing

Thank you for reading.

Warm Regards, Devarsh

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages