-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathlamda_trigger.mjs
39 lines (33 loc) · 980 Bytes
/
lamda_trigger.mjs
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
32
33
34
35
36
37
38
39
import https from "node:https";
export const handler = async (event) => {
const postdata = JSON.stringify({
username:
event.request.userAttributes["preferred_username"] || event.userName,
cognitoId: event.userName,
profilePictureUrl: "i1.jpg",
teamId: 1,
});
const opctions = {
hostname: "https://2yk8eg8yxd.execute-api.us-east-1.amazonaws.com/prod",
port: 443,
path: "/create-user",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": postdata.length,
},
};
const responseBody = await new Promise((resolve, reject) => {
const req = https.request(opctions, (res) => {
/* console.log(`statusCode: ${res.statusCode}`) */
res.setEncoding("utf8");
let body = "";
res.on("data", (chunk) => (body += chunk));
res.on("end", () => resolve(body));
});
req.on("error", reject);
req.write(postdata);
req.end();
});
return event();
};