Last active
August 29, 2015 14:24
-
-
Save u-minor/072d80f187873fda0444 to your computer and use it in GitHub Desktop.
API Gateway + Lambda で SNS にメッセージ投稿する ref: http://qiita.com/u-minor/items/f1eb05b3d333e8cc45a6
This file contains 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
aws --region us-east-1 lambda create-function \ | |
--function-name lambda-newrelic-sns \ | |
--runtime nodejs \ | |
--role arn:aws:iam::xxxxxxxx:role/lambda_sns_execution \ | |
--handler index.handler \ | |
--description 'Send message to Amazon SNS' \ | |
--timeout 3 \ | |
--memory-size 128 \ | |
--zip-file fileb://dist/lambda.zip |
This file contains 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
topicArn = 'YOUR_TOPIC_ARN' | |
snsRegion = 'ap-northeast-1' | |
AWS = require 'aws-sdk' | |
AWS.config.update region: snsRegion | |
sns = new AWS.SNS() | |
exports.handler = (event, context) -> | |
params = | |
Message: JSON.stringify(default: JSON.stringify(event)) | |
MessageStructure: 'json' | |
Subject: event.condition_name | |
TopicArn: topicArn | |
sns.publish params, (err, data) -> | |
if err | |
context.done null, err | |
return | |
context.done null, 'Post succeeded.' | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment