-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserverless.yml
158 lines (133 loc) · 3.76 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
service: gtmGithubHook
plugins:
- serverless-webpack
- serverless-kms-secrets
- serverless-offline
provider:
name: aws
runtime: nodejs8.10
memorySize: 2048 # optional, in MB, default is 1024
timeout: 60 # optional, in seconds, default is 6
stage: ${env:GTM_AWS_STAGE, 'dev'}
region: ${env:GTM_AWS_REGION}
environment: ${file(./serverless-aws-environment.yml):environment}
iamRoleStatements:
- Effect: Allow
Action:
- sqs:SendMessage
Resource:
Fn::GetAtt: [ PendingQueue, Arn ]
- Effect: Allow
Action:
- sqs:ReceiveMessage
- sqs:DeleteMessage
Resource:
Fn::GetAtt: [ ResultsQueue, Arn ]
- Effect: Allow
Action:
- dynamodb:UpdateItem
Resource:
Fn::GetAtt: [ EventsTable, Arn ]
- Effect: Allow
Action:
- dynamodb:UpdateItem
Resource:
Fn::GetAtt: [ AgentsTable, Arn ]
package:
individually: true
exclude:
- ".*/**"
functions:
gtmGithubHook:
handler: dist/src/serverless/gtmGithubHook/gtmGithubHook.listener
environment:
SQS_PENDING_QUEUE_URL:
Ref: PendingQueue
package:
include:
- dist/src/serverless/gtmGithubHook/**
events:
- http:
path: gtm-github-hook
method: post
cors: true
gtmGithubResults:
handler: dist/src/serverless/gtmGithubResults/gtmGithubResults.handle
environment:
SQS_RESULTS_QUEUE_URL:
Ref: ResultsQueue
package:
include:
- dist/src/serverless/gtmGithubResults/**
events:
- sns: ${env:GTM_SNS_RESULTS_TOPIC}
gtmGithubMetricCapture:
handler: dist/src/serverless/gtmGithubMetricCapture/gtmGithubMetricCapture.handler
environment:
DYNAMO_DB_TABLE_EVENTS:
Ref: EventsTable
DYNAMO_DB_TABLE_AGENTS:
Ref: AgentsTable
package:
include:
- dist/src/serverless/gtmGithubMetricCapture/**
events:
- cloudwatchLog:
logGroup: 'gtmAgent'
filter: '{$.resultType != ""}'
resources:
Resources:
PendingQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${env:GTM_SQS_PENDING_QUEUE}
MessageRetentionPeriod: 1209600
VisibilityTimeout: 7200
ResultsQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${env:GTM_SQS_RESULTS_QUEUE}
MessageRetentionPeriod: 1209600
VisibilityTimeout: 7200
EventsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${env:GTM_DYNAMO_TABLE_EVENTS}
AttributeDefinitions:
- AttributeName: ghEventId
AttributeType: S
KeySchema:
- AttributeName: ghEventId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
StreamSpecification:
StreamViewType: NEW_IMAGE
AgentsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${env:GTM_DYNAMO_TABLE_AGENTS}
AttributeDefinitions:
- AttributeName: agentId
AttributeType: S
KeySchema:
- AttributeName: agentId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
StreamSpecification:
StreamViewType: NEW_IMAGE
GtmS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${env:GTM_S3_DEPENDENCY_BUCKET}
# add additional custom bucket configuration here
# DynamoVpcEndpoint:
# Type: AWS::EC2::VPCEndpoint
# Properties:
# ServiceName: com.amazonaws.${env:GTM_AWS_REGION}.dynamodb
# VpcId: ${env:GTM_AWS_VPC_ID}
custom:
kmsSecrets: ${file(kms-secrets.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml)}