-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
152 lines (144 loc) · 3.65 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
service: smgco-360-uploader
provider:
name: aws
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'eu-west-1'}
runtime: nodejs18.x
resourcePolicy:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
Condition:
IpAddress:
aws:SourceIp:
- 167.98.25.201
- 54.154.192.59
- 34.253.155.4
- 87.81.144.34
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Scan
- dynamodb:DeleteItem
Resource:
- { "Fn::GetAtt": ["360ImagesDynamoDBTable", "Arn" ] }
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
- s3:PutObjectAcl
- s3:PutObjectTagging
- s3:PutObjectVersionAcl
- s3:PutObjectVersionTagging
- s3:DeleteObject
Resource:
- "arn:aws:s3:::${opt:bucket, 'smgco-360'}/*"
environment:
TABLE_NAME: { "Ref": "360ImagesDynamoDBTable" }
S3_BUCKET: ${opt:bucket, 'smgco-360'}
REGION: ${self:provider.region}
STAGE: ${self:provider.stage}
stackTags:
System: CollectionsOnline
functions:
listObjects:
handler: lambda/listObjects/index.handler
timeout: 90
events:
- http:
path: list-objects
method: get
cors: true
processFile:
handler: lambda/processFile/index.handler
timeout: 90
toggleStatus:
handler: lambda/toggleStatus/index.handler
timeout: 90
events:
- http:
path: toggle-status
method: post
cors: true
uploadForm:
handler: lambda/uploadForm/index.handler
timeout: 90
events:
- http:
path: /
method: get
cors: true
deleteObject:
handler: lambda/deleteObject/index.handler
timeout: 90
events:
- http:
path: /delete-object
method: post
cors: true
resources:
Resources:
360ImagesDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
S3Bucket360:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: ${opt:bucket, 'smgco-360'}
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
AllowedOrigins:
- "*"
NotificationConfiguration:
LambdaConfigurations:
- Event: "s3:ObjectCreated:*"
Function:
"Fn::GetAtt": [ ProcessFileLambdaFunction, Arn ]
ProcessFileLambdaPermissionS3Bucket360:
DependsOn:
- ProcessFileLambdaFunction
Type: AWS::Lambda::Permission
Properties:
FunctionName:
"Fn::GetAtt": [ ProcessFileLambdaFunction, Arn ]
Action: "lambda:InvokeFunction"
Principal: "s3.amazonaws.com"
SourceArn: "arn:aws:s3:::${opt:bucket, 'smgco-360'}"
360BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: S3Bucket360
PolicyDocument:
Statement:
Action: "s3:GetObject"
Effect: "Allow"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- Ref: S3Bucket360
- "/*"
Principal: "*"
plugins:
- serverless-offline