-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
117 lines (111 loc) · 3.93 KB
/
template.yaml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: BokuBot
Globals:
Function:
MemorySize: 512
Timeout: 300
Runtime: nodejs12.x
AutoPublishAlias: Latest
EventInvokeConfig:
MaximumRetryAttempts: 0
Resources:
BokuMentionLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: mention-lambda/built/mention-lambda/src/
Handler: index.handler
Layers:
- !Ref BokuBotDepLayer
Events:
BokuAPI:
Type: Api
Properties:
Path: /
Method: any
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref BokuTable
- DynamoDBCrudPolicy:
TableName: !Ref BokuMemeFeedbackTable
Environment:
Variables:
SLACK_ACCESS_TOKEN: '{{resolve:ssm:BOKU_BOT_SLACK_ACCESS_TOKEN:1}}'
SLACK_VERIFICATION_TOKEN: '{{resolve:ssm:BOKU_BOT_SLACK_VERIFICATION_TOKEN:1}}'
IMAGE_FLIP_USERNAME: '{{resolve:ssm:IMAGE_FLIP_USERNAME:1}}'
IMAGE_FLIP_PASSWORD: '{{resolve:ssm:IMAGE_FLIP_PASSWORD:1}}'
DYNAMO_TABLE_NAME: !Ref BokuTable
BOKU_MEME_FEEDBACK_TABLE: !Ref BokuMemeFeedbackTable
GOOGLE_API_KEY: '{{resolve:ssm:GOOGLE_API_KEY:1}}'
GOOGLE_SEARCH_ENGINE_ID: '{{resolve:ssm:GOOGLE_SEARCH_ENGINE_ID:1}}'
DEEP_AI_API_KEY: '{{resolve:ssm:DEEP_AI_API_KEY:1}}'
BokuActionLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: action-lambda/built/action-lambda/src
Handler: index.handler
Layers:
- !Ref BokuBotDepLayer
Events:
BokuAPI:
Type: Api
Properties:
Path: /action
Method: any
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref BokuMemeFeedbackTable
Environment:
Variables:
BOKU_MEME_FEEDBACK_TABLE: !Ref BokuMemeFeedbackTable
BokuBotDepLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: boku-bot-dependencies
Description: Dependencies for boku bot
ContentUri: dependencies/
CompatibleRuntimes:
- nodejs12.x
LicenseInfo: 'MIT'
RetentionPolicy: Retain
BokuTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: SlackMessageId
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
TableName: BokuRequestsTable
Tags:
Name: BokuTable
BokuMemeFeedbackTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
-
AttributeName: UserId
KeyType: HASH
-
AttributeName: ImageUrl
KeyType: RANGE
AttributeDefinitions:
-
AttributeName: ImageUrl
AttributeType: S
-
AttributeName: UserId
AttributeType: S
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
TableName: BokuMemeFeedback
Tags:
-
Key: Name
Value: BokuMemeFeedbackTable
Outputs:
ApiURL:
Description: "API endpoint URL"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/resource/"