## Setup * Create VPC * Create 2 Subnets under it * Connect both subnets to same routing table * Add Internetgateway to routing table * Connect EC2 to one of the subnets * Start instance and connect ## Install node on ec2 instance curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash . ~/.nvm/nvm.sh nvm install node # Check node # * IAM - Roles & Policies - Users & Groups - Access Type - Programmatic & Console - User will be in a Group and also given Role or attached with some policies # TODO - Create User and provide programmatic & console access - Attach Admin Policy - Download export AWS_DEFAULT_REGION=us-east-1 export AWS__REGION=us-east-1 export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= # Start node server var http = require("http"); http.createServer(function (request, response) { // Send the HTTP header // HTTP Status: 200 : OK // Content Type: text/plain response.writeHead(200, {'Content-Type': 'text/plain'}); // Send the response body as "Hello World" response.end('Hello World\n'); }).listen(8081); // Console will print the message console.log('Server running at http://127.0.0.1:8081/'); #### Talk to another server.. const http = require('http'); //load with local ip //http.get('http://172.31.36.226:8081', (resp) => { http.get('http://18.217.220.5:8081', (resp) => { let data = ''; // A chunk of data has been recieved. resp.on('data', (chunk) => { data += chunk; }); // The whole response has been received. Print out the result. resp.on('end', () => { console.log(data); }); }).on("error", (err) => { console.log("Error: " + err.message); }); # IAM permissions - Using ENV Variables of User - Using AWS credentials inside application - Passing AWS credentials dynamically to application - Attach role to EC2 instane on which application is running