This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "guardutyalert", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "damitj", | |
"license": "ISC", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0", | |
"id": "c8c4daa7-a20c-2f03-0070-b7393dd542ad", | |
"detail-type": "GuardDuty Finding", | |
"source": "aws.guardduty", | |
"account": "123456789012", | |
"time": "1970-01-01T00:00:00Z", | |
"region": "us-east-1", | |
"resources": [], | |
"detail": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = async(event) => { | |
var Slack = require('slack-node'); | |
var slack = new Slack(); | |
var webhookUri = process.env.SLACK_HOOK ? process.env.SLACK_HOOK : "https://hooks.slack.com/services/your/slack/hook"; | |
slack.setWebhook(webhookUri); | |
console.log(event.region); | |
console.log(event.detail.severity); | |
console.log(event.detail.service.additionalInfo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.reviews.createIndex( | |
{ | |
subject: "text", | |
comments: "text" | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
_id: 1, | |
item: "abc", | |
stock: [ | |
{ size: "S", color: "red", quantity: 25 | |
}, | |
{ size: "S", color: "blue", quantity: 10 | |
}, | |
{ size: "M", color: "blue", quantity: 50 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
executionStats: { | |
"executionSuccess": true, | |
"nReturned": 3, | |
"executionTimeMillis": 0, | |
"totalKeysExamined": 3, | |
"totalDocsExamined": 3, | |
"executionStages": {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> db.findOne(id : xyz, Person).then((data) => { | |
// data = Hydrate(data); | |
data.name = 'new name'; | |
data.title = 'Mrs'; | |
db.save(data, Person).then((result) => { | |
resolve(result); | |
}); | |
}); | |
>> db.updateFields(Person, { query: { id: data.id }, fields: { $set: { name: 'new Name', title: 'Mrs' } } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ _id: ObjectId(), a: 1, b: "ab" } | |
{ _id: ObjectId(), a: 2, b: "cd" } | |
{ _id: ObjectId(), a: 3, b: "ef" } | |
{ _id: ObjectId(), a: 4, b: "jk" } | |
{ _id: ObjectId(), a: 5, b: "lm" } | |
{ _id: ObjectId(), a: 6, b: "no" } | |
{ _id: ObjectId(), a: 7, b: "pq" } | |
{ _id: ObjectId(), a: 8, b: "rs" } | |
{ _id: ObjectId(), a: 9, b: "tv" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ _id: ObjectId(), a: 1, b: "ab" } | |
{ _id: ObjectId(), a: 1, b: "cd" } | |
{ _id: ObjectId(), a: 1, b: "ef" } | |
{ _id: ObjectId(), a: 2, b: "jk" } | |
{ _id: ObjectId(), a: 2, b: "lm" } | |
{ _id: ObjectId(), a: 2, b: "no" } | |
{ _id: ObjectId(), a: 3, b: "pq" } | |
{ _id: ObjectId(), a: 3, b: "rs" } | |
{ _id: ObjectId(), a: 3, b: "tv" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.products.findOne() | |
{ | |
name : 'left-handed smoke shifter', | |
manufacturer : 'Acme Corp', | |
catalog_number: 1234, | |
parts : [ | |
{ id : ObjectID('AAAA'), name : '#4 grommet' }, // Part name is denormalised | |
{ id: ObjectID('F17C'), name : 'fan blade assembly' }, | |
{ id: ObjectID('D2AA'), name : 'power switch' }, | |
// etc |
NewerOlder