assertible / lambda-cloudwatch-slack Goto Github PK
View Code? Open in Web Editor NEWSend AWS CloudWatch notifications to a Slack channel using Lambda
Home Page: https://assertible.com/blog/npm-package-lambda-cloudwatch-slack
License: MIT License
Send AWS CloudWatch notifications to a Slack channel using Lambda
Home Page: https://assertible.com/blog/npm-package-lambda-cloudwatch-slack
License: MIT License
Hi Team,
We are having some strange issue with the ASG notification, sometime the autoscaling Name is appearing in the specified filed and some time it is not appearing.
Some times it does appear like this.
, but to verify not an issue with the SNS , we have mail subscription enabled for the same SNA topic and we are receiving all the relevant information in the mail, but not in the Slack.
we have 4 ASGs and especially this is happening with one of the ASG name all the times, and for the remaining it is intermittent , so not sure what could be the issue.
same thing happening for termination alerts also.
Please help us here. Thanks.
Failed at run npm run deploy.
npm-debug.log
The message looks like:
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:XXXXXXXXXXXXXXX-monitoring:9b9asdff5-be7f-safa-958a-000000000000",
"Sns": {
"Type": "Notification",
"MessageId": "318b60f7-fae6sdfd-5fasd93-ae63-XXXXXXXXXX",
"TopicArn": "arn:aws:sns:XXXXXXXXXXXXXX-monitoring",
"Subject": "Test - AWS Cloudwatch - Lamda",
"Message": "Test - AWS Cloudwatch - Lamda",
"Timestamp": "2019-03-07T07:00:50.306Z",
"SignatureVersion": "1",
"Signature": "Kmdfh5Lr5LpBeTXgZJRdPHohmHRdQn6NmXXXXXXXXXXXXXXXXXXXXXXXXXxthnjHorUS+BNbW9892imFRcH==",
"SigningCertUrl": "https://sns.XXXXXXXXXXX.pem",
"UnsubscribeUrl": "https://sns.XXXXXXXXXXX958a-a3sd12jf4l3ka4s8d",
"MessageAttributes": {}
}
}
]
}
Records[0].Sns.Message is no object in this case and JSON.parse fails here:
index.js:319 var message = JSON.parse(record.Sns.Message)
Check if Records[0].Sns.Message is a object:
index.js:319 var message = typeof record.Sns.Message === 'object'
index.js:320 ? JSON.parse(record.Sns.Message)
index.js:321 : { message: record.Sns.Message}
Hi, looks like a great function, thank you!
While deployment works, and npm test
works, the actual function doesn't. Whenever the lambda function triggers, it posts this error.
module initialization error: Error
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.Module._extensions..js (module.js:662:20)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
I've tried with permissions to set every file to 777, tried zipping and manual upload.
Any ideas?
Hi, I have multiple AWS accounts and am setting this up to send CloudWatch messages to one specific Slack channel. I would like to be able to determine quickly which account triggered the alert rather than being redirected to it's url. Did anybody else also implement this?
Hello All --
I was wondering if you could help me with the error I am running into. I've used lambda-cloudwatch-slack before on another AWS account. Now I need to install it again on my new AWS account. Do you know where I am going wrong?
processing cloudwatch notification
message posted successfully
/home/ec2-user/lambda-cloudwatch-slack/index.js:299
context.succeed();
^
TypeError: context.succeed is not a function
at /home/ec2-user/lambda-cloudwatch-slack/index.js:299:15
at IncomingMessage. (/home/ec2-user/lambda-cloudwatch-slack/index.js:38:9)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:913:12)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickDomainCallback (node.js:397:17)
make: *** [test] Error 1
Hi,
I've everything set-up correctly and before using the lambda function, I wanted to test it by creating a new test (from AWS Console) and selected the CloudWatch template, once executed it gives this error:
Cannot read property '0' of undefined
at processEvent (/var/task/index.js:321:43)
at exports.handler (/var/task/index.js:369:5)
Any clue?
We have set up alerts on various CodeDeploy events to come via the lambda (great tool btw, thanks!) to a Slack channel. Unfortunately the Slack messages are missing most of the relevant detail.
Looking at the test data in the repo and comparing it to the actual event that came through from SNS it looks like the event's format might have changed.
Compare test/sns-codedeploy-event.json
with
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:xxxxxxxx:name:uuid",
"Sns": {
"Type": "Notification",
"MessageId": "uuid",
"TopicArn": "arn:aws:sns:eu-west-1:xxxxxxxx:name",
"Subject": null,
"Message": "{\"version\":\"0\",\"id\":\"uuid\",\"detail-type\":\"CodeDeploy Deployment State-change Notification\",\"source\":\"aws.codedeploy\",\"account\":\"xxxxxxx\",\"time\":\"2020-05-05T09:53:00Z\",\"region\":\"eu-west-1\",\"resources\":[\"arn:aws:codedeploy:eu-west-1:xxxxxx:deploymentgroup:name/name\",\"arn:aws:codedeploy:eu-west-1:xxxxxx:application:name\"],\"detail\":{\"region\":\"eu-west-1\",\"deploymentId\":\"id\",\"instanceGroupId\":\"uuid\",\"deploymentGroup\":\"name\",\"state\":\"SUCCESS\",\"application\":\"name\"}}",
"Timestamp": "2020-05-05T09:53:00.502Z",
"SignatureVersion": "1",
"Signature": "XXXXXXXXXXXXX",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/cert.pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn",
"MessageAttributes": {}
}
}
]
}
(data redacted to remove any sensitive info)
Am I right in thinking that the SNS payload has changed? In which case, I would be willing to do a PR to reflect these changes if that would help.
I found that url.parse being deprecated meant that the requests were going to localhost.
I had to modify that start of the postMessage() function to this:
var postMessage = function(message, callback) {
var body = JSON.stringify(message);
const urlObject = new url()
let options = {
hostname: urlObject.host,
method: 'POST',
path: urlObject.pathname,
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(body),
}
};
var postReq = https.request(options, function(res) {
...
Running on Ubuntu Windows. All looks to be installed correctly.
Here is my npm debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'deploy' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle [email protected]predeploy: [email protected]predeploy: no script for predeploy, continuing
6 silly lifecycle [email protected]
7 info lifecycle [email protected]deploy: [email protected]deploy: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
9 verbose lifecycle [email protected]deploy: PATH: /usr/share/npm/bin/node-gyp-bin:/mnt/c/Users/ernest.vanduyne/PycharmProjects/aurora-backup/lambda-cloudwatch-slack-master/node_modules/.bin:/home/erniev/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64__79rhkp1fndgsc:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Program Files/Amazon/AWSCLI/bin:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files/dotnet:/mnt/c/Users/ernest.vanduyne/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ernest.vanduyne/AppData/Local/JetBrains/PyCharm Community Edition 2019.1.1/bin:/mnt/c/Users/ernest.vanduyne/AppData/Local/Programs/Git/cmd:/snap/bindeploy: CWD: /mnt/c/Users/ernest.vanduyne/PycharmProjects/aurora-backup/lambda-cloudwatch-slack-master
10 verbose lifecycle [email protected]
11 silly lifecycle [email protected]deploy: Args: [ '-c', './scripts/deploy.sh' ]deploy: Returned: code: 1 signal: null
12 silly lifecycle [email protected]
13 info lifecycle [email protected]~deploy: Failed to exec deploy script
14 verbose stack Error: [email protected] deploy: ./scripts/deploy.sh
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:126:13)
14 verbose stack at EventEmitter.emit (events.js:214:7)
14 verbose stack at ChildProcess. (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack at emitTwo (events.js:126:13)
14 verbose stack at ChildProcess.emit (events.js:214:7)
14 verbose stack at maybeClose (internal/child_process.js:925:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
15 verbose pkgid [email protected]
16 verbose cwd /mnt/c/Users/ernest.vanduyne/PycharmProjects/aurora-backup/lambda-cloudwatch-slack-master
17 error Linux 4.4.0-17763-Microsoft
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "deploy"
19 error node v8.10.0
20 error npm v3.5.2
21 error code ELIFECYCLE
22 error [email protected] deploy: ./scripts/deploy.sh
22 error Exit status 1
23 error Failed at the [email protected] deploy script './scripts/deploy.sh'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the lambda-cloudwatch-slack package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error ./scripts/deploy.sh
23 error You can get information on how to open an issue for this project with:
23 error npm bugs lambda-cloudwatch-slack
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls lambda-cloudwatch-slack
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
-I followed the README.txt. The "make deploy" was successful.
-I created the SNS topic.
-I created the SNS subscription.
-I ran a test trigger using the github test CloudWatch notification template. That was successful.
-I added my lambda function to the CloudWatch Alarm.
Now when I force an alarm to fire off, I see that the SNS was received. The correct template is chosen, but i get the following message in my CloudWatch logs:
{
"errorMessage": "no matching processor for event"
}
Where do I go from here? Please let me know if you have any suggestions for me.
#1 implemented a bunch of great stuff and now the README needs to be updated with the newest usage instructions. See original PR for more info.
Hello,
This is currently broken because AWS no longer support Node.js 12. Please upgrade this to a newer version of Node.js so that this application remains functional. It really is a great tool and I would love to continue using it. I appreciate your help!
Thanks,
Austin
how to clean all data after test
any command line of npm to destroy all data in AWS environment
When I do npm run deploy
, this is what I get in the terminal. The lambda upload function doesn't complete, and later fails with a timeout. Does anyone have any clues as to why this is happening? Thanks!
=> Running npm install --production
=> Zipping deployment package
=> Zipping repo. This might take up to 30 seconds
=> Reading zip file to memory
=> Reading event source file to memory
=> Uploading zip file to AWS Lambda eu-east-1 with parameters:
{ FunctionName: 'cloudwatch-to-slack-2',
Code: { ZipFile: <Buffer 50 4b 03 04 14 00 08 00 08 00 a4 ab 39 4e 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 2e 44 53 5f 53 74 6f 72 65 ed 57 4d 6c dc 54 10 9e 6f b3 4d ... > },
Handler: 'index.handler',
Role: 'arn:aws:iam::xxxxxxxxxxx:role/cloudwatch-to-slack-role',
Runtime: 'nodejs8.10',
Description: 'Better Slack notifications for AWS CloudWatch',
MemorySize: 128,
Timeout: 60,
Publish: false,
VpcConfig: { SubnetIds: [], SecurityGroupIds: [] },
Environment: { Variables: { UNENCRYPTED_HOOK_URL: 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXX } },
KMSKeyArn: '',
DeadLetterConfig: { TargetArn: null },
TracingConfig: { Mode: null } }
{ Error: connect ETIMEDOUT 92.242.140.21:443
at Object._errnoException (util.js:1041:11)
at _exceptionWithHostPort (util.js:1064:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1153:14)
message: 'connect ETIMEDOUT 92.242.140.21:443',
code: 'NetworkingError',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '92.242.140.21',
port: 443,
region: 'eu-east-1',
hostname: 'lambda.eu-east-1.amazonaws.com',
retryable: true,
time: 2019-01-25T21:31:56.154Z }
Am I right in my view that the keys needed for a make deploy to complete need to be a user with full access to lambda? I can't seem to get past the following error during the make deploy -
TracingConfig: { Mode: null } }
The security token included in the request is invalid.
=> Retrying
{ [UnrecognizedClientException: The security token included in the request is invalid.]
message: 'The security token included in the request is invalid.',
code: 'UnrecognizedClientException',
time: Wed Jan 03 2018 17:08:09 GMT+0000 (GMT),
requestId: 'abf21363-f0a8-11e7-a226-4b1e45b4187b',
statusCode: 403,
retryable: false,
retryDelay: 40.62163548078388 }
Makefile:38: recipe for target 'deploy' failed
make: *** [deploy] Error 1
I have tried various combinations of .aws entries, exported commandline variables and values within Makefile with no joy.
Hi,
I have multiple channels for a single slack Webhook.
how to i send the notification on a particular channel. i didn't see any variable of that in .env file.
Hi ,
It was stopped working from last two weeks. and I am getting this error in cloudwatch logs.
Error: Runtime exited with error: exit status 1 Runtime.ExitError
Error: certificate has expired
at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
Not sure which certification it is looking for. Can you please help with this.
Please do let me know if you required any more details for debugging purpose. Thanks in advance.
What are the exact permissions needed for npm run deploy
to work? A User with AdministratorAccess has too much access.
When I run npm run deploy
with below permission I get:
User: arn:aws:iam::xxxxxxxx:user/xxxxxxxx is not authorized to perform: iam:PassRole on resource: arn:aws:iam::xxxxxxxx:role/xxxxxxxx
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:GetFunction",
"lambda:CreateFunction"
],
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME"
}
]
}
lambda-cloudwatch-slack-0.1.2
1.when code deploy to aws ,cloudwatch log show:
No matching processor for event. [EventSubscriptionArn: arn:aws:sns:ap-southeast-1:426052853157:staging-asg:51e5c7bb-9436-43c6-8cd6-33fa7aa748d5]
Error: connect ECONNREFUSED 127.0.0.1:443
at Object.exports._errnoException (util.js:1016:11)
at exports._exceptionWithHostPort (util.js:1039:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1138:14)
make: *** [test] Error 1
Thanks for this! I went ahead and made a port to Fleep.
You could add this in your ReadMe if you want.
Repo: https://github.com/pasevin/lambda-cloudwatch-fleep
It does not work anymore.
InvalidParameterValueException:The runtime parameter of nodejs8.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs12.x) while creating or updating functions.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
System info
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
node : v11.0.0
npm: 6.5.0
npm test
> [email protected] test /home/dharshan/workspace/tries/lambda-cloudwatch-slack
> ./scripts/test.sh
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14
Object.defineProperty(obj, name, {
^
TypeError: Cannot redefine property: pseudoRandomBytes
at Function.defineProperty (<anonymous>)
at defineProperty (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:14:10)
at wrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:56:3)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:76:7
at Array.forEach (<anonymous>)
at /home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:75:11
at Array.forEach (<anonymous>)
at massWrap (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/shimmer/index.js:74:11)
at Object.<anonymous> (/home/dharshan/workspace/tries/lambda-cloudwatch-slack/node_modules/async-listener/index.js:332:3)
at Module._compile (internal/modules/cjs/loader.js:707:30)
npm ERR! Test failed. See above for more details.
In .env
file I can specify one webhook_url
. Can I specify multiple webhook_url
s. So that I can post one notification to group and get one personally?
Hi,
I´m trying running the deploy script, houwever i receiving the follow message.
`> [email protected] deploy /home/ubuntu/lambda-cloudwatch-slack
./scripts/deploy.sh
=> Moving files to temporary directory
Error: Cannot copy '.' to a subdirectory of itself, '/home/ubuntu/lambda-cloudwatch-slack/lambda-cloudwatch-slack-lambda'.
at checkStats (/home/ubuntu/lambda-cloudwatch-slack/node_modules/fs-extra/lib/copy/copy.js:240:17)
at fs.stat (/home/ubuntu/lambda-cloudwatch-slack/node_modules/fs-extra/lib/copy/copy.js:227:14)
at callback (/home/ubuntu/lambda-cloudwatch-slack/node_modules/graceful-fs/polyfills.js:295:20)
at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! Linux 4.15.0-1056-aws
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "deploy"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] deploy: ./scripts/deploy.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script './scripts/deploy.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the lambda-cloudwatch-slack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./scripts/deploy.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs lambda-cloudwatch-slack
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls lambda-cloudwatch-slack
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/lambda-cloudwatch-slack/npm-deb
npm-debug.log
ug.log
`
ubuntu@api-h-beholder:~/lambda-cloudwatch-slack$ npm -v 3.5.2 ubuntu@api-h-beholder:~/lambda-cloudwatch-slack$ ubuntu@api-h-beholder:~/lambda-cloudwatch-slack$ node -v v8.10.0
Hi,
First off thanks for putting it all together.
I wanted to use this stack only for CloudWatch alerts and AutoScale Notification. I am after deploying it on my AWS account, I am successfully able to receive message from CloudWatch. But not getting events of AutoScale.
Just to troubleshoot i have tried to run make test. To do so i have removed all json files from test folder except context.json
sns-autoscaling-event.json
I am getting below error message. Though same test is working while i am putting all test json files in test folder
/opt/lambda-cloudwatch-slack/test/sns-cloudwatch-event.json file successfully created
sns received:{
"key": "value",
"key2": "value2",
"other_key": "other_value"
}
/opt/lambda-cloudwatch-slack/index.js:268
var eventSubscriptionArn = event.Records[0].EventSubscriptionArn;
^
TypeError: Cannot read property '0' of undefined
at processEvent (/opt/lambda-cloudwatch-slack/index.js:268:43)
at exports.handler (/opt/lambda-cloudwatch-slack/index.js:316:5)
at Lambda._runHandler (/opt/lambda-cloudwatch-slack/node_modules/node-lambda/lib/main.js:97:7)
at Lambda.run (/opt/lambda-cloudwatch-slack/node_modules/node-lambda/lib/main.js:54:8)
at Command.<anonymous> (/opt/lambda-cloudwatch-slack/node_modules/node-lambda/bin/node-lambda:99:12)
at Command.listener (/opt/lambda-cloudwatch-slack/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:191:7)
at Command.parseArgs (/opt/lambda-cloudwatch-slack/node_modules/commander/index.js:615:12)
at Command.parse (/opt/lambda-cloudwatch-slack/node_modules/commander/index.js:458:21)
make: *** [test] Error 1
Could you please help me know to know what i am missing here?
-Rohit
Hi,
I have deployed this function to a customer AWS account and it works great! However as with the Go version of this code i am facing an issue. These functions can only handle JSON Formatted strings, and one of our customers forwards syslog to cloudwatch via awslogs i believe, and that doesnt get forwarded to slack because its not formatted correctly. Is this a feature you will work on in the future? I will attempt it myself in the meantime in the handleCatchAll, but I am not that good of a programmer.
Thanks
Due recent changes on Lambda state changes Lambda deployment fails because of the ResourceConflictException.
More information about the changes on AWS side:
https://aws.amazon.com/blogs/compute/tracking-the-state-of-lambda-functions/
Is this going to be fixed?
Since I am working with AWS IAM console for first time, I would like to know which are all the only required permissions for a new IAM user.
Service: lambda
Access level
- List
- ?
- ?
- Read
- ?
- ?
- Write
- ?
- ?
- Permissions management
- ?
- ?
I'm facing bellow issue
User: arn:aws:iam::2731640429:user/cloudwatch-to-slack-user is not authorized to perform: iam:PassRole on resource: arn:aws:iam::2731640429:role/cloudwatch-to-slack-role
Hi,
Do you think it be possible to add support for GuardDuty message format,
Using as is the sample output from GuardDuty looks like this:
Message Description version: 0 id: 94fc31e1-8e7f-0234-12d6-4baa425fe901 detail-type: GuardDuty Finding source: aws.guardduty account: *** time: 2019-03-02T21:25:06Z region: eu-west-1 resources: [] detail: {"schemaVersion":"2.0","accountId":"***","region":"eu-west-1","partition":"aws","id":"00b4a024780657c85f1befc2286e957f","arn":"arn:aws:guardduty:eu-west-1:***:detector/1cb46e3bff812aa163e14334dd9751b4/finding/00b4a024780657c85f1befc2286e957f","type":"Persistence:IAMUser/NetworkPermissions","resource":{"resourceType":"AccessKey","accessKeyDetails":{"accessKeyId":"GeneratedFindingAccessKeyId","principalId":"GeneratedFindingPrincipalId","userType":"IAMUser","userName":"GeneratedFindingUserName"}},"service":{"serviceName":"guardduty","detectorId":"1cb46e3bff812aa163e14334dd9751b4","action":{"actionType":"AWS_API_CALL","awsApiCallAction":{"api":"GeneratedFindingAPIName","serviceName":"GeneratedFindingAPIServiceName","callerType":"Remote IP","remoteIpDetails":{"ipAddressV4":"198.51.100.0","organization":{"asn":"-1","asnOrg":"GeneratedFindingASNOrg","isp":"GeneratedFindingISP","org":"GeneratedFindingORG"},"country":{"countryName":"GeneratedFindingCountryName"},"city":{"cityName":"GeneratedFindingCityName"},"geoLocation":{"lat":0,"lon":0}},"affectedResources":{}}},"resourceRole":"TARGET","additionalInfo":{"recentApiCalls":[{"api":"GeneratedFindingAPIName1","count":2},{"api":"GeneratedFindingAPIName2","count":2}],"sample":true},"eventFirstSeen":"2019-03-02T21:21:55.724Z","eventLastSeen":"2019-03-02T21:21:55.724Z","archived":false,"count":1},"severity":5,"createdAt":"2019-03-02T21:21:55.724Z","updatedAt":"2019-03-02T21:21:55.724Z","title":"Unusual changes to network permissions by GeneratedFindingUserName.","description":"APIs commonly used to change the network access permissions for security groups, routes and ACLs, was invoked by IAM principal GeneratedFindingUserName. Such activity is not typically seen from this principal."}
Hi,
I have integrated slack notification via SNS with your code & notification triggered successfully from OK to Alarm state, But it is not triggering if the state coming from Alarm to OK.
Is the functionality is not there OR i am missing something ?
Can you please help me with this ?
Looks like a great lambda implementation, would love to use it, but it seems to be doing something odd.
First, Lambda's default SNS test event causes this failure:
2017-11-28T19:37:15.286Z 1a21cdd9-d473-11e7-89a1-a3392781a961 SyntaxError: Unexpected token T
at Object.parse (native)
at handleCatchAll (/var/task/index.js:282:24)
at processEvent (/var/task/index.js:347:20)
at exports.handler (/var/task/index.js:370:5)
Second, I sent Elastic Beanstalk events through SNS to this Lambda code, and strangely enough it was being handled by the catch-all, not the Elastic Beanstalk handler.
And, those Beanstalk events would fail with the exact same error above.
Hi,
When I run the npm run deploy I got below error:
message: The runtime parameter of nodejs8.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs12.x) while creating or updating functions.
So I run npm install node-lambda@latest
and deploy was successful.
Now when I send a test message to subscription I get below error in Lambda:
2020-04-01T10:46:49.840Z xxxxxxxxxxxxxxxxxxxxx INFO sns received:
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "xxx",
"Sns": {
"Type": "Notification",
"MessageId": "xxxxx",
"TopicArn": "xxx",
"Subject": "test",
"Message": "test",
"Timestamp": "2020-04-01T10:43:53.616Z",
"SignatureVersion": "1",
"Signature": "xxxxxx",
"SigningCertUrl": "xxx",
"UnsubscribeUrl": "xxx",
"MessageAttributes": {}
}
}
]
}
2020-04-01T10:46:49.841Z xxxxx ERROR Invoke Error
{
"errorType": "SyntaxError",
"errorMessage": "Unexpected token e in JSON at position 1",
"stack": [
"SyntaxError: Unexpected token e in JSON at position 1",
" at JSON.parse (<anonymous>)",
" at handleCatchAll (/var/task/index.js:319:24)",
" at processEvent (/var/task/index.js:395:20)",
" at Runtime.exports.handler (/var/task/index.js:415:5)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
}
Any possibility of adding in a function to handle S3 Events, e.g. puts or deletes.
Hey @CodyReichert and the Assertible team, thanks again for this very useful module. I'm having some problem getting it to work. I've changed the settings in the Makefile:
LAMBDA_TEST?=./node_modules/node-lambda/bin/node-lambda
LAMBDA_FUNCTION_NAME=cloudwatch-to-slack
AWS_REGION=us-east-1
AWS_ROLE=arn:aws:iam::XXXXX
AWS_PROFILE=myprofile
AWS_ACCESS_KEY_ID=XXXXX
AWS_ACCESS_KEY_SECRET=XXXXX
and also in the config.js
:
kmsEncryptedHookUrl: "<kmsEncryptedHookUrl>", // encrypted slack webhook url
unencryptedHookUrl: "https://hooks.slack.com/services/XXXXX", // unencrypted slack webhook url
slackChannel: "#aws"
(the rest of the settings in config.js
are left unchanged.)
I then run npm install
and make test
, and it works perfectly. The four sample notifications were posted to our slack channel. Yay!
Since the current version of the README ends here, I played around and figured that I needed to run make deploy
to use this in production (I also added the AWS_ACCESS_KEY_ID
and AWS_ACCESS_KEY_SECRET
while doing this). So I ran this, and it worked great as well.
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Reading zip file to memory
=> Uploading zip file to AWS Lambda us-east-1 with parameters:
{ FunctionName: 'cloudwatch-to-slack-development',
Code: { ZipFile: <Buffer 50 4b 03 04 14 00 00 00 08 00 77 60 1e 49 0e 26 12 34 f4 01 00 00 28 05 00 00 09 00 1c 00 63 6f 6e 66 69 67 2e 6a 73 55 54 09 00 03 62 ae c5 57 62 ae ... > },
Handler: 'index.handler',
Role: 'XXXXX',
Runtime: 'nodejs4.3',
Description: 'Better Slack notifications for AWS CloudWatch',
MemorySize: '128',
Timeout: '3',
Publish: false,
VpcConfig: {} }
=> Zip file(s) done uploading. Results follow
All look good. I wait for a bit but receives no notification on the Slack channel, so I decide to check the AWS Lambda page on the console. I then choose Test => Configure test event => Cloudwatch logs in the sample event template. The test result looks like:
START RequestId: 9073e2c4-6ed2-11e6-874d-837e65e4596f Version: $LATEST
2016-08-30T16:55:36.213Z 9073e2c4-6ed2-11e6-874d-837e65e4596f sns received:{
"awslogs": {
"data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA=="
}
}
2016-08-30T16:55:36.252Z 9073e2c4-6ed2-11e6-874d-837e65e4596f TypeError: Cannot read property '0' of undefined
at processEvent (/var/task/index.js:223:43)
at exports.handler (/var/task/index.js:267:5)
END RequestId: 9073e2c4-6ed2-11e6-874d-837e65e4596f
REPORT RequestId: 9073e2c4-6ed2-11e6-874d-837e65e4596f Duration: 3584.87 ms Billed Duration: 3600 ms Memory Size: 128 MB Max Memory Used: 26 MB
Process exited before completing request
, which indicates that there's some bug with the module (I don't know nodejs, just purely guessing), or that I'm doing something wrong and the notification is not being posted correctly.
Any suggestion would be greatly appreciated, thanks!
Hello! I've deployed the bot, but I have not set up any flow for Alarms to go into SNS queues, so there is nothing for the bot to process. Is there any suggested documentation/blog post on how to do that?
Hello, I operate in a controlled AWS account where I can create Roles and attach Policies but I cannot create or affect Users. I have to request someone do that for me. I would like to setup this function inside that AWS account.
What perms does the User need? I assume LambdaFullAccess at the very least but does it need any others?
AWS recently sent this email to all users with lambdas using Node.js 8.10:
We are contacting you as we have identified that your AWS Account currently has one or more Lambda functions using Node.js 8.10, which will reach its EOL at the end of 2019.
What’s happening?
The Node community has decided to end support for Node.js 8.x on December 31, 2019 [1]. From this date forward, Node.js 8.x will stop receiving bug fixes, security updates, and/or performance improvements. To ensure that your new and existing functions run on a supported and secure runtime, language runtimes that have reached their EOL are deprecated in AWS [2].
For Node.js 8.x, there will be 2 stages to the runtime deprecation process:
Disable Function Create – Beginning January 6, 2020, customers will no longer be able to create functions using Node.js 8.10
Disable Function Update – Beginning February 3, 2020, customers will no longer be able to update functions using Node.js 8.10
After this period, both function creation and updates will be disabled permanently. However, existing Node 8.x functions will still be available to process invocation events.
What do I need to do?
We encourage you to update all of your Node.js 8.10 functions to the newer available runtime version, Node.js 10.x[3]. You should test your functions for compatibility with the Node.js 10.x language version before applying changes to your production functions.
Can this be addressed in configuration? Is there a way to update this without redeploying? If I do redeploy will it mess up the existing configuration?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.