Skip to content

Commit

Permalink
Add Delete request for github hook resource
Browse files Browse the repository at this point in the history
  • Loading branch information
mwunsch committed Jul 20, 2016
1 parent 9500ca3 commit 96ce7f6
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions formation.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"ZipFile": { "Fn::Join": ["\n", [
"const response = require('cfn-response');",
"const http = require('https');",
"const url = require('url');",
"exports.handler = function(event, context) {",
" var props = event.ResourceProperties;",
" var options = {",
Expand All @@ -220,7 +221,7 @@
" aws_region: 'us-east-1'",
" }",
" };",
" var req = http.request(opt, (res) => {;",
" var req = http.request(opt, (res) => {",
" var body = '';",
" res.on('data', (chunk) => body += chunk.toString());",
" res.on('end', () => {",
Expand All @@ -235,9 +236,29 @@
" req.setTimeout(500);",
" req.write(JSON.stringify(hook));",
" req.end();",
" } else if (event.RequestType === 'Delete') {",
" console.log(`CFN Delete:\\n ${JSON.stringify(event)}`);",
" var opt = Object.assign({",
" path: url.parse(event.PhysicalResourceId).pathname,",
" method: 'DELETE'",
" }, options);",
" var req = http.request(opt, (res) => {",
" var body = '';",
" res.on('data', (chunk) => body += chunk.toString());",
" res.on('end', () => {",
" console.log(`GitHub Status: ${res.statusCode} ${res.statusMessage} ; Body:\\n ${body}`);",
" if (res.statusCode === 204) {",
" response.send(event, context, response.SUCCESS);",
" } else {",
" response.send(event, context, response.FAILED);",
" };",
" });",
" });",
" req.setTimeout(500);",
" req.end();",
" } else {",
" /* ¯\\_(ツ)_/¯ */",
" console.log(`CFN Delete:\\n ${JSON.stringify(event)}`);",
" console.log(`CFN Request:\\n ${JSON.stringify(event)}`);",
" response.send(event, context, response.SUCCESS);",
" };",
"};"
Expand Down

0 comments on commit 96ce7f6

Please sign in to comment.