Closed3
AWS SNSを利用してslackに通知を飛ばす
やりたいこと
CDKでインフラ構築
前提
- cdk typescript を利用
- aws-cdk v2.50.0
SNSとnotifyLambda
// SQS, SNS の用意
this.sns_topic = new Topic(
this, "crypto-notifier-sns"
)
this.deadLetterQueue = new Queue(this, 'deadLetterQueue');
// notifyLambdaにsnsに関する権限を付与
const snsTopicPolicy = new PolicyStatement({
actions: ['sns:*'],
resources: ['*'],
});
// Slack通知用Lambda
this.slackNotifyLambda = new NodejsFunction(this, 'slack-notify-lambda', {
entry: path.join(__dirname, '../lambda-fns/slack-notifier.js'),
functionName: 'slack-notifier',
handler: 'handler',
runtime: Runtime.NODEJS_16_X,
bundling: {
nodeModules: ['phin']
},
environment: {
HOOK_URL: slack_webhook,
},
});
this.slackNotifyLambda.addEventSource(new SnsEventSource(
this.sns_topic, {
deadLetterQueue: this.deadLetterQueue
})
)
このスクラップは2023/06/30にクローズされました