-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
92 lines (84 loc) · 2.2 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
90
91
92
service:
name: readme-counter
plugins:
- serverless-webpack
- serverless-plugin-iam-checker
- serverless-prune-versions
- serverless-plugin-test-helper
- serverless-cloudformation-resource-counter
- serverless-plugin-thundra
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, env:STAGE, env:USER}
logRetentionInDays: 14
httpApi:
cors: true
payload: "2.0"
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
LAMBDA_WRAPPER_LOG: true
VISITS_TABLE: !Ref VisitsTable
VISITS_TOPIC: !Ref VisitsTopic
thundra_apiKey: ${opt:thundra, env:THUNDRA_TOKEN}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Query
- dynamodb:Scan
Resource:
- !GetAtt VisitsTable.Arn
- Effect: Allow
Action:
- sns:Publish
Resource:
- !Ref VisitsTopic
custom:
topic: ${self:service.name}-visits-${self:provider.stage}
# Serverless plugin configurations
# https://github.com/manwaring/serverless-prune-versions
prune:
automatic: true
number: 2
# https://github.com/drexler/serverless-cloudformation-resource-counter
warningThreshold: 100
# https://github.com/serverless-heaven/serverless-webpack
webpack:
includeModules: true
excludeFiles: src/**/*.test.[t|j]s
functions:
get-readme-badge:
handler: src/get-badge.handler
events:
- httpApi: GET /v1/readme/visits/{vcs}/{owner}/{repository}
record-visit:
handler: src/record-visit.handler
events:
- sns:
arn: !Ref VisitsTopic
topicName: ${self:custom.topic}
update-orgs:
handler: src/update-orgs.handler
resources:
Resources:
VisitsTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:custom.topic}
VisitsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
BillingMode: PAY_PER_REQUEST