-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
93 lines (84 loc) · 2.46 KB
/
Copy pathserverless.yml
File metadata and controls
93 lines (84 loc) · 2.46 KB
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
# "org" ensures this Service is used with the correct Serverless Framework Access Key.
org: raveri
# "app" enables Serverless Framework Dashboard features and sharing them with other Services.
app: shopify-erp-serverless-integration
# "service" is the name of this project. This will also be added to your AWS resource names.
service: shopify-erp-serverless-integration
provider:
name: aws
runtime: nodejs20.x
region: eu-central-1
stage: dev
logs:
lambda:
logFormat: JSON
environment:
WEBHOOK_SIGNATURE: ${env:WEBHOOK_SIGNATURE}
ORDER_QUEUE_URL:
Ref: OrderQueue
DYNAMODB_TABLE: OrderTable
ERROR_ALERT_TOPIC_ARN:
Ref: ErrorNotificationTopic
iamRoleStatements:
- Effect: Allow
Action:
- sqs:SendMessage
- dynamodb:PutItem
- dynamodb:GetItem
- sns:Publish
Resource:
- arn:aws:sqs:${self:provider.region}:${aws:accountId}:OrderQueue
- arn:aws:dynamodb:${self:provider.region}:${aws:accountId}:table/OrderTable
- arn:aws:sns:${self:provider.region}:${aws:accountId}:lambda-error-notification-topic
functions:
receiveWebhook:
handler: src/handlers/handleWebhook.handler
events:
- http:
path: webhook/order
method: post
processOrder:
handler: src/handlers/processOrder.handler
events:
- sqs:
arn:
Fn::GetAtt: [OrderQueue, Arn]
batchSize: 1
errorNotifier:
handler: src/handlers/notifyError.handler
events:
- cloudwatchLog:
logGroup: /aws/lambda/${self:service}-${self:provider.stage}-processOrder
filter: '"ERROR"'
useDotenv: true
resources:
Resources:
OrderQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: OrderQueue
OrderTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: OrderTable
AttributeDefinitions:
- AttributeName: orderId
AttributeType: S
KeySchema:
- AttributeName: orderId
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
ErrorNotificationTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: lambda-error-notification-topic
ErrorNotificationSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: email
Endpoint: lucaraveri993@gmail.com
TopicArn:
Ref: ErrorNotificationTopic