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" } } },