Skip to content

Instantly share code, notes, and snippets.

@u-minor
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u-minor/072d80f187873fda0444 to your computer and use it in GitHub Desktop.
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
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
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