-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.ts
98 lines (94 loc) · 2.75 KB
/
serverless.ts
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
import type { AWS } from '@serverless/typescript';
import { functions, dynamoDb, eventBridge, } from './resources';
const serverlessConfiguration: AWS = {
service: 'iofinnet-qa-interview-test-eventbridge',
frameworkVersion: '3',
plugins: [
'serverless-esbuild',
'serverless-offline',
'serverless-offline-aws-eventbridge',
'serverless-dynamodb-local',
],
package: {
individually: true,
},
params: {
default: {
DATA_TABLE: 'iofinnet-qa-interview-test-dynamodb-${sls:stage}',
EVENT_BRIDGE_NAME: 'iofinnet-qa-interview-eventbridge-${sls:stage}'
},
},
provider: {
name: 'aws',
runtime: 'nodejs16.x',
stage: 'test',
region: 'eu-west-1',
environment: {
DATA_TABLE: '${param:DATA_TABLE}',
EVENT_BRIDGE_NAME: '${param:EVENT_BRIDGE_NAME}',
EVENT_BRIDGE_OFFLINE_PORT: '${self:custom.serverless-offline-aws-eventbridge.port}',
EVENT_BRIDGE_OFFLINE_HOST: '${self:custom.serverless-offline-aws-eventbridge.hostname}',
},
httpApi: {
shouldStartNameWithService: true,
disableDefaultEndpoint: false,
},
iamRoleStatements: [
{
Effect: 'Allow',
Action: ['events:PutEvents'],
Resource: [
'arn:aws:events:${aws:region}:${aws:accountId}:event-bus/${param:EVENT_BRIDGE_NAME}',
],
},
{
Effect: 'Allow',
Action: ['dynamodb:Query', 'dynamodb:BatchWriteItem', 'dynamodb:PutItem'],
Resource: [
'arn:aws:dynamodb:${aws:region}:${aws:accountId}:table/${param:DATA_TABLE}',
],
},
],
},
custom: {
esbuild: {
bundle: true,
minify: true,
sourcemap: false,
packager: 'npm',
exclude: ['aws-sdk'],
target: 'node16',
platform: 'node',
watch: {
pattern: ['src/**/*.ts'],
},
},
'serverless-offline-aws-eventbridge': {
port: 4010, // port to run the eventBridge mock server on
mockEventBridgeServer: true, // Set to false if EventBridge is already mocked by another stack
hostname: "127.0.0.1", // IP or hostname of existing EventBridge if mocked by another stack
pubSubPort: 4011, // Port to run the MQ server (or just listen if using an EventBridge mock server from another stack)
debug: true, // flag to show debug messages
account: '123456789' // account id that gets passed to the event
},
dynamodb: {
stages: ['test'],
start: {
port: 8000,
inMemory: true,
heapInitial: '200m',
heapMax: '1g',
migrate: 'true',
convertEmptyValues: 'true'
}
}
},
functions: { ...functions },
resources: {
Resources: {
...eventBridge?.Resources,
...dynamoDb?.Resources
},
},
};
module.exports = serverlessConfiguration;