feat: フォルダ名称変更と、node.jsの資材を削除

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-01-26 09:23:23 +09:00
parent a297976ea0
commit c162f05e8c
8 changed files with 0 additions and 97 deletions

View File

@ -1,37 +0,0 @@
"use-strict";
const request = require("request-promise");
exports.handler = (event, context, callback) => {
const attaches = event.Records.map(evt => {
return {
"fallback":`Notification from mbj-newdwh2021 AWS: ${evt.EventSubscriptionArn}`,
"pretext":`Notification from mbj-newdwh2021 AWS: ${evt.EventSubscriptionArn}`,
"color":"#0000D0",
"fields":[
{
"title": `${evt.Sns.Subject}`,
"value": `${evt.Sns.Timestamp}: ${evt.Sns.Message} (MessageId: ${evt.Sns.MessageId})`,
"short": false
}
]
};
});
request({
method: "POST",
url: process.env.webhookurl,
body: {
attachments: attaches
},
json: true
}).then((body => {
callback(null, `Request succeed. ${body}`);
})).catch((err) => {
callback("failed to request to slack.", {
result: "ERROR",
event: event,
cause: `request failed. ${err}.`
});
})
};

View File

@ -1,15 +0,0 @@
{
"name": "mbj-newdwh2021-staging-noticetoslack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"request": "^2.88.2",
"request-promise": "^4.2.6"
}
}

View File

@ -1,30 +0,0 @@
const zlib = require("zlib");
const aws = require("aws-sdk");
const sns = new aws.SNS({
apiVersion: "2010-03-31",
region: 'ap-northeast-1'
});
exports.handler = function(input, context) {
var payload = new Buffer.from(input.awslogs.data, 'base64');
zlib.gunzip(payload, function(e, result) {
if (e) {
context.fail(e);
} else {
result = JSON.parse(result.toString('UTF-8'));
const publishMessage = {
Subject: `Detect Error(or Warning) in ${result.logGroup}`,
Message: result.logEvents.map((l) => l.message).join('\n'),
TopicArn: process.env.topicArn
};
console.log(publishMessage);
sns.publish(publishMessage, (err, data) => {
console.log(err, data);
if(err){
context.fail(err);
}
});
}
});
};

View File

@ -1,15 +0,0 @@
{
"name": "mbj-newdwh2021-staging-publishfromlog",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.1011.0",
"zlib": "^1.0.5"
}
}