-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsam.yml
73 lines (73 loc) · 1.99 KB
/
sam.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'Publish messages received from SNS to Slack'
Resources:
EventPublishSnsSubscription:
Type: 'AWS::SNS::Subscription'
Properties:
TopicArn:
'Fn::ImportValue':
Ref: SnsPublisherTopicExport
Protocol: lambda
Endpoint:
'Fn::GetAtt':
- SlackPublish
- Arn
SlackResponseSnsTopic:
Type: 'AWS::SNS::Topic'
SlackPublish:
Type: 'AWS::Serverless::Function'
Properties:
Handler: handlers/aws_sns_to_slack_publisher.handler
Runtime: python3.6
Description: Publish message from SNS to Slack
MemorySize: 128
Timeout: 60
Environment:
Variables:
LOG_LEVEL: INFO
SLACK_API_TOKEN:
Ref: SlackApiToken
SLACK_DEFAULT_CHANNEL:
Ref: SlackDefaultChannel
SNS_PUBLISH_RESPONSE:
Ref: SnsPublishResponse
RESPONSE_SNS_TOPIC_ARN:
Ref: SlackResponseSnsTopic
Events:
SnsMessage:
Type: SNS
Properties:
Topic:
Fn::ImportValue:
Ref: SnsPublisherTopicExport
Policies:
- SNSPublishMessagePolicy:
TopicName:
Ref: SlackResponseSnsTopic
Outputs:
SlackResponseSnsTopicArn:
Description: AWS SNS Topic ARN
Value:
Ref: SlackResponseSnsTopic
Export:
Name:
Fn::Sub: ${AWS::StackName}-SlackResponseSnsTopicArn
Parameters:
SlackApiToken:
Type: String
Description: Slack API token
SlackDefaultChannel:
Type: String
Description: Slack channel to publish to.
Default: notifications
SnsPublishResponse:
Type: String
Description: Whether or not to publish function response to Sns
Default: 'false'
AllowedValues:
- true
- false
SnsPublisherTopicExport:
Type: String
Description: Name of the CloudFormation export wit the Sns topic ARN to subscribe to