Skip to content

Commit 4f62eb5

Browse files
Fix serverless.yml warnings
1 parent b3ade1a commit 4f62eb5

File tree

1 file changed

+49
-53
lines changed

1 file changed

+49
-53
lines changed

serverless.yml

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
service: swift-sprinter-rest-api
2+
variablesResolutionMode: 20210326
3+
configValidationMode: warn
24

35
package:
46
individually: true
57

8+
custom:
9+
tableName: 'products-table-${sls:stage}'
10+
611
provider:
712
name: aws
813
httpApi:
914
payload: '2.0'
15+
cors: true
1016
runtime: provided
17+
lambdaHashingVersion: "20201221"
1118
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] }
3440

3541
layers:
3642
swift-lambda-runtime:
@@ -43,94 +49,84 @@ functions:
4349
handler: build/Products.create
4450
package:
4551
individually: true
46-
exclude:
47-
- "**/*"
48-
include:
49-
- build/Products
52+
patterns:
53+
- "!**/*"
54+
- "build/Products"
5055
memorySize: 256
5156
layers:
52-
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
53-
description: "[${self:provider.stage}] Create Product"
57+
- { Ref: "SwiftDashlambdaDashruntimeLambdaLayer" }
58+
description: "[${sls:stage}] Create Product"
5459
events:
5560
- httpApi:
5661
path: /products
5762
method: post
58-
cors: true
5963
readProduct:
6064
handler: build/Products.read
6165
package:
6266
individually: true
63-
exclude:
64-
- "**/*"
65-
include:
66-
- build/Products
67+
patterns:
68+
- "!**/*"
69+
- "build/Products"
6770
memorySize: 256
6871
layers:
6972
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
70-
description: "[${self:provider.stage}] Get Product"
73+
description: "[${sls:stage}] Get Product"
7174
events:
7275
- httpApi:
7376
path: /products/{sku}
7477
method: get
75-
cors: true
7678
updateProduct:
7779
handler: build/Products.update
7880
package:
7981
individually: true
80-
exclude:
81-
- "**/*"
82-
include:
83-
- build/Products
82+
patterns:
83+
- "!**/*"
84+
- "build/Products"
8485
memorySize: 256
8586
layers:
8687
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
87-
description: "[${self:provider.stage}] Update Product"
88+
description: "[${sls:stage}] Update Product"
8889
events:
8990
- httpApi:
9091
path: /products
9192
method: put
92-
cors: true
9393
deleteProduct:
9494
handler: build/Products.delete
9595
package:
9696
individually: true
97-
exclude:
98-
- "**/*"
99-
include:
97+
patterns:
98+
- "!**/*"
10099
- build/Products
101100
memorySize: 256
102101
layers:
103102
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
104-
description: "[${self:provider.stage}] Delete Product"
103+
description: "[${sls:stage}] Delete Product"
105104
events:
106105
- httpApi:
107106
path: /products/{sku}
108107
method: delete
109-
cors: true
110108
listProducts:
111109
handler: build/Products.list
112110
package:
113111
individually: true
114-
exclude:
115-
- "**/*"
116-
include:
117-
- build/Products
112+
patterns:
113+
- "!**/*"
114+
- "build/Products"
118115
memorySize: 256
119116
layers:
120117
- { Ref: SwiftDashlambdaDashruntimeLambdaLayer }
121-
description: "[${self:provider.stage}] List Products"
118+
description: "[${sls:stage}] List Products"
122119
events:
123120
- httpApi:
124121
path: /products
125122
method: get
126-
cors: true
127123

128124
resources:
129125
Resources:
130126
ProductsTable:
131127
Type: AWS::DynamoDB::Table
132128
Properties:
133-
TableName: ${self:custom.productsTableName}
129+
TableName: ${self:custom.tableName}
134130
AttributeDefinitions:
135131
- AttributeName: sku
136132
AttributeType: S

0 commit comments

Comments
 (0)