-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 943 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const express = require('express');
const app = express();
app.get('/', function(req, res) {
console.log('Recieving home GET');
res.send(JSON.stringify({
reply: 200,
message: "Welcome, you are accessing a private endpoint..."
}))
});
app.get('/meta/host', function(req, res) {
let exec = require('child_process').exec;
let command = exec("curl http://169.254.169.254/latest/meta-data/public-hostname", async function (err, stdout, stderr) {
if (err) console.log('SOME ERROR: ' +err);
res.send(stdout);
});
});
app.get('/meta', function(req, res) {
let exec = require('child_process').exec;
let command = exec("curl http://169.254.169.254/latest/meta-data/", async function (err, stdout, stderr) {
if (err) console.log('SOME ERROR: ' +err);
res.send(JSON.stringify(stdout));
});
});
app.listen(3000, function() {
console.log('Listening on 3000');
});