-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
89 lines (82 loc) · 2.4 KB
/
serverless.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
service: t99-analytics
frameworkVersion: "=1.39.1"
provider:
name: aws
runtime: java8
stage: ${opt:stage, 'dev'}
region: ap-northeast-1
tracing: true
plugins:
- serverless-plugin-tracing
package:
artifact: target/scala-2.12/t99.jar
functions:
t99:
role: t99FunctionRole
handler: t99.lambda.Handler
timeout: 30
events:
- http:
path: execute
method: post
environment:
AUTH_TOKEN: ${env:T99_AUTH_TOKEN}
TWITTER_OAUTH2_BEARER_TOKEN: ${env:T99_TWITTER_OAUTH2_BEARER_TOKEN}
RESULT_TABLE_NAME: ${self:resources.Resources.t99ResultTable.Properties.TableName}
ENV: ${self:provider.stage}
resources:
Resources:
t99FunctionRole:
Type: AWS::IAM::Role
Properties:
Path: /
RoleName: T99FunctionRole-${self:provider.stage}
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: t99FunctionPolicy-${self:provider.stage}
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/*:*:*'
- Effect: Allow
Action:
- rekognition:DetectText
- xray:PutTraceSegments
- xray:PutTelemetryRecords
- dynamodb:PutItem
Resource: "*"
t99ResultTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: t99Result-${self:provider.stage}
AttributeDefinitions:
-
AttributeName: TweetId
AttributeType: S
KeySchema:
-
AttributeName: TweetId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5