-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
148 lines (135 loc) · 3.8 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
service: nostr-image-services-${sls:stage}
provider:
name: aws
runtime: nodejs16.x
region: eu-west-1
architecture: arm64
timeout: 29
# HTTP Api gateway
httpApi:
cors:
allowedMethods:
- GET
- POST
allowedOrigins: "*"
environment:
S3_BUCKET: ${self:custom.S3_BUCKET}
DYNAMODB_TABLE: ${self:service}
LNBITS_HOST: ${self:custom.LNBITS_HOST}
LNBITS_API_INVOICE_KEY: ${self:custom.LNBITS_API_INVOICE_KEY}
CLOUDFRONT_DOMAIN_NAME: ${self:custom.CLOUDFRONT_DOMAIN_NAME}
CF_CUSTOM_DOMAIN: ${self:custom.CF_CUSTOM_DOMAIN}
WEBHOOW_URL: !GetAtt HttpApi.ApiEndpoint
ALLOWED_IP: ${self:custom.ALLOWED_IP}
PRICE: ${self:custom.PRICE}
API_CUSTOM_DOMAIN: ${self:custom.API_CUSTOM_DOMAIN}
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
Resource:
- Fn::Join:
- ''
- - 'arn:aws:s3:::'
- ${self:custom.S3_BUCKET}
- '/*'
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:GetItem
- dynamodb:DeleteItem
Resource: { "Fn::GetAtt": [PaymentHashTableNstr, Arn] }
custom:
LNBITS_HOST: ${file(./variables.yml):LNBITS_HOST}
LNBITS_API_INVOICE_KEY: ${file(./variables.yml):LNBITS_API_INVOICE_KEY}
CLOUDFRONT_DOMAIN_NAME: ${file(./variables.yml):CLOUDFRONT_DOMAIN_NAME}
S3_BUCKET: ${file(./variables.yml):S3_BUCKET}
ALLOWED_IP: ${file(./variables.yml):ALLOWED_IP}
PRICE: ${file(./variables.yml):PRICE}
API_CUSTOM_DOMAIN: ${file(./variables.yml):API_CUSTOM_DOMAIN}
ROUTE53_ZONE_ID: ${file(./variables.yml):ROUTE53_ZONE_ID}
CF_CUSTOM_DOMAIN: ${file(./variables.yml):CF_CUSTOM_DOMAIN}
package:
individually: true
patterns:
- '!serverless.yml'
- '!variables.sample.yml'
- '!variables.yml'
functions:
paymentNotificationNstr:
handler: lambda/paymentNotification.paymentNotification
logRetentionInDays: 3
reservedConcurrency: 10
package:
individually: true
patterns:
- '!lambda/**'
- lambda/paymentNotification.js
events:
- httpApi:
path: /paymentNotification
method: POST
uploadFileNstr:
handler: lambda/uploadFile.uploadFile
logRetentionInDays: 3
reservedConcurrency: 10
package:
individually: true
patterns:
- '!lambda/**'
- lambda/uploadFile.js
events:
- httpApi:
path: /uploadFile
method: POST
checkPaymentNstr:
handler: lambda/checkPayment.checkPayment
logRetentionInDays: 3
reservedConcurrency: 10
package:
individually: true
patterns:
- '!lambda/**'
- lambda/checkPayment.js
events:
- httpApi:
path: /checkPayment
method: POST
getInvoiceNstr:
handler: lambda/getInvoice.getInvoice
logRetentionInDays: 3
reservedConcurrency: 10
package:
individually: true
patterns:
- '!lambda/**'
- lambda/getInvoice.js
events:
- httpApi:
path: /getInvoice
method: GET
resources:
Resources:
CertificateApiNstr:
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: ${self:custom.API_CUSTOM_DOMAIN}
ValidationMethod: DNS
DomainValidationOptions:
- DomainName: ${self:custom.API_CUSTOM_DOMAIN}
HostedZoneId: ${self:custom.ROUTE53_ZONE_ID}
# create dynamoDB table
PaymentHashTableNstr:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}
AttributeDefinitions:
- AttributeName: payment_hash
AttributeType: S
KeySchema:
- AttributeName: payment_hash
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5