From ba9b94dfeba460df1c07e53843288e10c7df28c5 Mon Sep 17 00:00:00 2001 From: nightfury1204 Date: Thu, 29 Aug 2024 16:46:58 +0100 Subject: [PATCH] Fix webhook resource --- provider/aws/templates/resource/webhook.tmpl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/provider/aws/templates/resource/webhook.tmpl b/provider/aws/templates/resource/webhook.tmpl index 6f6ac5368..0ac97918c 100644 --- a/provider/aws/templates/resource/webhook.tmpl +++ b/provider/aws/templates/resource/webhook.tmpl @@ -19,12 +19,24 @@ "var https = require(\"https\");", "var url = require(\"url\");", "exports.handler = (event, context, cb) => {", - " var req = https.request(Object.assign(url.parse(process.env.WEBHOOK_URL), { method:\"POST\" }), function(res) {;", - " cb(null);", + " var req = https.request(", + " Object.assign(url.parse(process.env.WEBHOOK_URL), { method: \"POST\" }),", + " function (res) {", + " let data = '';", + " res.on('data', (chunk) => {", + " data += chunk;", + " });", + " res.on('end', () => {", + " cb(null, 200);", + " });", + " }", + " );", + " req.on('error', (e) => {", + " cb(e);", " });", " req.write(event.Records[0].Sns.Message);", " req.end();", - "}" + "};" ] ] } }, "Environment": { "Variables": { "WEBHOOK_URL": { "Ref": "Url" } } },