1
1
service : swift-sprinter-rest-api
2
+ variablesResolutionMode : 20210326
3
+ configValidationMode : warn
2
4
3
5
package :
4
6
individually : true
5
7
8
+ custom :
9
+ tableName : ' products-table-${sls:stage}'
10
+
6
11
provider :
7
12
name : aws
8
13
httpApi :
9
14
payload : ' 2.0'
15
+ cors : true
10
16
runtime : provided
17
+ lambdaHashingVersion : " 20201221"
11
18
environment :
12
- PRODUCTS_TABLE_NAME : " ${self:custom.productsTableName}"
13
- iamRoleStatements :
14
- - Effect : Allow
15
- Action :
16
- - logs:CreateLogGroup
17
- - logs:CreateLogStream
18
- - logs:PutLogEvents
19
- Resource : " *"
20
- - Effect : Allow
21
- Action :
22
- - dynamodb:UpdateItem
23
- - dynamodb:PutItem
24
- - dynamodb:GetItem
25
- - dynamodb:DeleteItem
26
- - dynamodb:Query
27
- - dynamodb:Scan
28
- - dynamodb:DescribeTable
29
- Resource :
30
- - { Fn::GetAtt: [ProductsTable, Arn] }
31
-
32
- custom :
33
- productsTableName : products-table-${self:provider.stage}
19
+ PRODUCTS_TABLE_NAME : ' ${self:custom.tableName}'
20
+ iam :
21
+ role :
22
+ statements :
23
+ - Effect : Allow
24
+ Action :
25
+ - logs:CreateLogGroup
26
+ - logs:CreateLogStream
27
+ - logs:PutLogEvents
28
+ Resource : " *"
29
+ - Effect : Allow
30
+ Action :
31
+ - dynamodb:UpdateItem
32
+ - dynamodb:PutItem
33
+ - dynamodb:GetItem
34
+ - dynamodb:DeleteItem
35
+ - dynamodb:Query
36
+ - dynamodb:Scan
37
+ - dynamodb:DescribeTable
38
+ Resource :
39
+ - { Fn::GetAtt: [ProductsTable, Arn] }
34
40
35
41
layers :
36
42
swift-lambda-runtime :
@@ -43,94 +49,84 @@ functions:
43
49
handler : build/Products.create
44
50
package :
45
51
individually : true
46
- exclude :
47
- - " **/*"
48
- include :
49
- - build/Products
52
+ patterns :
53
+ - " !**/*"
54
+ - " build/Products"
50
55
memorySize : 256
51
56
layers :
52
- - { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
53
- description : " [${self:provider. stage}] Create Product"
57
+ - { Ref: " SwiftDashlambdaDashruntimeLambdaLayer" }
58
+ description : " [${sls: stage}] Create Product"
54
59
events :
55
60
- httpApi :
56
61
path : /products
57
62
method : post
58
- cors : true
59
63
readProduct :
60
64
handler : build/Products.read
61
65
package :
62
66
individually : true
63
- exclude :
64
- - " **/*"
65
- include :
66
- - build/Products
67
+ patterns :
68
+ - " !**/*"
69
+ - " build/Products"
67
70
memorySize : 256
68
71
layers :
69
72
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
70
- description : " [${self:provider. stage}] Get Product"
73
+ description : " [${sls: stage}] Get Product"
71
74
events :
72
75
- httpApi :
73
76
path : /products/{sku}
74
77
method : get
75
- cors : true
76
78
updateProduct :
77
79
handler : build/Products.update
78
80
package :
79
81
individually : true
80
- exclude :
81
- - " **/*"
82
- include :
83
- - build/Products
82
+ patterns :
83
+ - " !**/*"
84
+ - " build/Products"
84
85
memorySize : 256
85
86
layers :
86
87
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
87
- description : " [${self:provider. stage}] Update Product"
88
+ description : " [${sls: stage}] Update Product"
88
89
events :
89
90
- httpApi :
90
91
path : /products
91
92
method : put
92
- cors : true
93
93
deleteProduct :
94
94
handler : build/Products.delete
95
95
package :
96
96
individually : true
97
- exclude :
98
- - " **/*"
99
- include :
97
+ patterns :
98
+ - " !**/*"
100
99
- build/Products
101
100
memorySize : 256
102
101
layers :
103
102
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
104
- description : " [${self:provider. stage}] Delete Product"
103
+ description : " [${sls: stage}] Delete Product"
105
104
events :
106
105
- httpApi :
107
106
path : /products/{sku}
108
107
method : delete
109
- cors : true
110
108
listProducts :
111
109
handler : build/Products.list
112
110
package :
113
111
individually : true
114
- exclude :
115
- - " **/*"
116
- include :
117
- - build/Products
112
+ patterns :
113
+ - " !**/*"
114
+ - " build/Products"
118
115
memorySize : 256
119
116
layers :
120
117
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
121
- description : " [${self:provider. stage}] List Products"
118
+ description : " [${sls: stage}] List Products"
122
119
events :
123
120
- httpApi :
124
121
path : /products
125
122
method : get
126
- cors : true
127
123
128
124
resources :
129
125
Resources :
130
126
ProductsTable :
131
127
Type : AWS::DynamoDB::Table
132
128
Properties :
133
- TableName : ${self:custom.productsTableName }
129
+ TableName : ${self:custom.tableName }
134
130
AttributeDefinitions :
135
131
- AttributeName : sku
136
132
AttributeType : S
0 commit comments