Skip to content

Commit 048ee36

Browse files
committed
Use tests instead of curl
1 parent 0cd2b0b commit 048ee36

File tree

12 files changed

+354
-261
lines changed

12 files changed

+354
-261
lines changed

examples/serverless-rest-example/.serverless/cloudformation-template-create-stack.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,46 @@
1515
]
1616
}
1717
}
18+
},
19+
"ServerlessDeploymentBucketPolicy": {
20+
"Type": "AWS::S3::BucketPolicy",
21+
"Properties": {
22+
"Bucket": {
23+
"Ref": "ServerlessDeploymentBucket"
24+
},
25+
"PolicyDocument": {
26+
"Statement": [
27+
{
28+
"Action": "s3:*",
29+
"Effect": "Deny",
30+
"Principal": "*",
31+
"Resource": [
32+
{
33+
"Fn::Join": [
34+
"",
35+
[
36+
"arn:",
37+
{
38+
"Ref": "AWS::Partition"
39+
},
40+
":s3:::",
41+
{
42+
"Ref": "ServerlessDeploymentBucket"
43+
},
44+
"/*"
45+
]
46+
]
47+
}
48+
],
49+
"Condition": {
50+
"Bool": {
51+
"aws:SecureTransport": false
52+
}
53+
}
54+
}
55+
]
56+
}
57+
}
1858
}
1959
},
2060
"Outputs": {

examples/serverless-rest-example/.serverless/cloudformation-template-update-stack.json

Lines changed: 72 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,46 @@
1616
}
1717
}
1818
},
19+
"ServerlessDeploymentBucketPolicy": {
20+
"Type": "AWS::S3::BucketPolicy",
21+
"Properties": {
22+
"Bucket": {
23+
"Ref": "ServerlessDeploymentBucket"
24+
},
25+
"PolicyDocument": {
26+
"Statement": [
27+
{
28+
"Action": "s3:*",
29+
"Effect": "Deny",
30+
"Principal": "*",
31+
"Resource": [
32+
{
33+
"Fn::Join": [
34+
"",
35+
[
36+
"arn:",
37+
{
38+
"Ref": "AWS::Partition"
39+
},
40+
":s3:::",
41+
{
42+
"Ref": "ServerlessDeploymentBucket"
43+
},
44+
"/*"
45+
]
46+
]
47+
}
48+
],
49+
"Condition": {
50+
"Bool": {
51+
"aws:SecureTransport": false
52+
}
53+
}
54+
}
55+
]
56+
}
57+
}
58+
},
1959
"GetItemsLogGroup": {
2060
"Type": "AWS::Logs::LogGroup",
2161
"Properties": {
@@ -59,8 +99,8 @@
5999
"Fn::Join": [
60100
"-",
61101
[
62-
"dev",
63102
"serverless-rest-example",
103+
"dev",
64104
"lambda"
65105
]
66106
]
@@ -71,7 +111,8 @@
71111
{
72112
"Effect": "Allow",
73113
"Action": [
74-
"logs:CreateLogStream"
114+
"logs:CreateLogStream",
115+
"logs:CreateLogGroup"
75116
],
76117
"Resource": [
77118
{
@@ -129,7 +170,7 @@
129170
"S3Bucket": {
130171
"Ref": "ServerlessDeploymentBucket"
131172
},
132-
"S3Key": "serverless/serverless-rest-example/dev/1578327566259-2020-01-06T16:19:26.259Z/serverless-rest-example.zip"
173+
"S3Key": "serverless/serverless-rest-example/dev/1617033989378-2021-03-29T16:06:29.378Z/serverless-rest-example.zip"
133174
},
134175
"FunctionName": "serverless-rest-example-dev-getItems",
135176
"Handler": "dist/manageItems.getItem",
@@ -149,18 +190,17 @@
149190
}
150191
},
151192
"DependsOn": [
152-
"GetItemsLogGroup",
153-
"IamRoleLambdaExecution"
193+
"GetItemsLogGroup"
154194
]
155195
},
156-
"GetItemsLambdaVersion0FdbsMpyGuJGkKPLMcXz2O5Fr6A6PAjphkZd9wRWqLs": {
196+
"GetItemsLambdaVersionjYYW7X8gqUHuD34wTZmIV6TNxI7OeAKAwazJ5PGBpM": {
157197
"Type": "AWS::Lambda::Version",
158198
"DeletionPolicy": "Retain",
159199
"Properties": {
160200
"FunctionName": {
161201
"Ref": "GetItemsLambdaFunction"
162202
},
163-
"CodeSha256": "tB+t5SkNOxx+QNxQ4E2ftCoMGs3colDyH5EWcUn0o84="
203+
"CodeSha256": "2Ogo6/XiGDOAWloKcUs3YA4M1KpInrt2bhFfliigu5g="
164204
}
165205
},
166206
"UpdateItemsLambdaFunction": {
@@ -170,7 +210,7 @@
170210
"S3Bucket": {
171211
"Ref": "ServerlessDeploymentBucket"
172212
},
173-
"S3Key": "serverless/serverless-rest-example/dev/1578327566259-2020-01-06T16:19:26.259Z/serverless-rest-example.zip"
213+
"S3Key": "serverless/serverless-rest-example/dev/1617033989378-2021-03-29T16:06:29.378Z/serverless-rest-example.zip"
174214
},
175215
"FunctionName": "serverless-rest-example-dev-updateItems",
176216
"Handler": "dist/manageItems.updateItem",
@@ -190,18 +230,17 @@
190230
}
191231
},
192232
"DependsOn": [
193-
"UpdateItemsLogGroup",
194-
"IamRoleLambdaExecution"
233+
"UpdateItemsLogGroup"
195234
]
196235
},
197-
"UpdateItemsLambdaVersionTayhisxd9gbffpM8BhEkLl3y2PpIgnLCT1tTmLvTNc": {
236+
"UpdateItemsLambdaVersions6tcDejjJko6UQQ4aRF4DGweb0oLvV7s6OCVeMCVk": {
198237
"Type": "AWS::Lambda::Version",
199238
"DeletionPolicy": "Retain",
200239
"Properties": {
201240
"FunctionName": {
202241
"Ref": "UpdateItemsLambdaFunction"
203242
},
204-
"CodeSha256": "tB+t5SkNOxx+QNxQ4E2ftCoMGs3colDyH5EWcUn0o84="
243+
"CodeSha256": "2Ogo6/XiGDOAWloKcUs3YA4M1KpInrt2bhFfliigu5g="
205244
}
206245
},
207246
"DeleteItemsLambdaFunction": {
@@ -211,7 +250,7 @@
211250
"S3Bucket": {
212251
"Ref": "ServerlessDeploymentBucket"
213252
},
214-
"S3Key": "serverless/serverless-rest-example/dev/1578327566259-2020-01-06T16:19:26.259Z/serverless-rest-example.zip"
253+
"S3Key": "serverless/serverless-rest-example/dev/1617033989378-2021-03-29T16:06:29.378Z/serverless-rest-example.zip"
215254
},
216255
"FunctionName": "serverless-rest-example-dev-deleteItems",
217256
"Handler": "dist/manageItems.deleteItem",
@@ -231,18 +270,17 @@
231270
}
232271
},
233272
"DependsOn": [
234-
"DeleteItemsLogGroup",
235-
"IamRoleLambdaExecution"
273+
"DeleteItemsLogGroup"
236274
]
237275
},
238-
"DeleteItemsLambdaVersionstQHAgwZsjbq0blNOuxbWh7M1sPoPdkGEjJUqQNx9w": {
276+
"DeleteItemsLambdaVersionZAG3AryC7HWe11S5T6bykH2MwzO5ymRkGYbnEEC5k": {
239277
"Type": "AWS::Lambda::Version",
240278
"DeletionPolicy": "Retain",
241279
"Properties": {
242280
"FunctionName": {
243281
"Ref": "DeleteItemsLambdaFunction"
244282
},
245-
"CodeSha256": "tB+t5SkNOxx+QNxQ4E2ftCoMGs3colDyH5EWcUn0o84="
283+
"CodeSha256": "2Ogo6/XiGDOAWloKcUs3YA4M1KpInrt2bhFfliigu5g="
246284
}
247285
},
248286
"ApiGatewayRestApi": {
@@ -253,7 +291,8 @@
253291
"Types": [
254292
"EDGE"
255293
]
256-
}
294+
},
295+
"Policy": ""
257296
}
258297
},
259298
"ApiGatewayResourceItem": {
@@ -283,7 +322,7 @@
283322
}
284323
}
285324
},
286-
"ApiGatewayMethodItemOptions": {
325+
"ApiGatewayMethodItemItemidVarOptions": {
287326
"Type": "AWS::ApiGateway::Method",
288327
"Properties": {
289328
"AuthorizationType": "NONE",
@@ -294,8 +333,7 @@
294333
"ResponseParameters": {
295334
"method.response.header.Access-Control-Allow-Origin": true,
296335
"method.response.header.Access-Control-Allow-Headers": true,
297-
"method.response.header.Access-Control-Allow-Methods": true,
298-
"method.response.header.Access-Control-Allow-Credentials": true
336+
"method.response.header.Access-Control-Allow-Methods": true
299337
},
300338
"ResponseModels": {}
301339
}
@@ -313,24 +351,23 @@
313351
"ResponseParameters": {
314352
"method.response.header.Access-Control-Allow-Origin": "'*'",
315353
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
316-
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,POST,GET'",
317-
"method.response.header.Access-Control-Allow-Credentials": "'false'"
354+
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,DELETE,POST,GET'"
318355
},
319356
"ResponseTemplates": {
320-
"application/json": "#set($origin = $input.params(\"Origin\"))\n#if($origin == \"\") #set($origin = $input.params(\"origin\")) #end\n#if($origin.matches(\".*\")) #set($context.responseOverride.header.Access-Control-Allow-Origin = $origin) #end"
357+
"application/json": "#set($origin = $input.params(\"Origin\"))\n#if($origin == \"\") #set($origin = $input.params(\"origin\")) #end\n#if($origin.matches(\".+\")) #set($context.responseOverride.header.Access-Control-Allow-Origin = $origin) #end"
321358
}
322359
}
323360
]
324361
},
325362
"ResourceId": {
326-
"Ref": "ApiGatewayResourceItem"
363+
"Ref": "ApiGatewayResourceItemItemidVar"
327364
},
328365
"RestApiId": {
329366
"Ref": "ApiGatewayRestApi"
330367
}
331368
}
332369
},
333-
"ApiGatewayMethodItemItemidVarOptions": {
370+
"ApiGatewayMethodItemOptions": {
334371
"Type": "AWS::ApiGateway::Method",
335372
"Properties": {
336373
"AuthorizationType": "NONE",
@@ -341,8 +378,7 @@
341378
"ResponseParameters": {
342379
"method.response.header.Access-Control-Allow-Origin": true,
343380
"method.response.header.Access-Control-Allow-Headers": true,
344-
"method.response.header.Access-Control-Allow-Methods": true,
345-
"method.response.header.Access-Control-Allow-Credentials": true
381+
"method.response.header.Access-Control-Allow-Methods": true
346382
},
347383
"ResponseModels": {}
348384
}
@@ -360,64 +396,20 @@
360396
"ResponseParameters": {
361397
"method.response.header.Access-Control-Allow-Origin": "'*'",
362398
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
363-
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,DELETE,POST,GET'",
364-
"method.response.header.Access-Control-Allow-Credentials": "'false'"
399+
"method.response.header.Access-Control-Allow-Methods": "'OPTIONS,POST'"
365400
},
366401
"ResponseTemplates": {
367-
"application/json": "#set($origin = $input.params(\"Origin\"))\n#if($origin == \"\") #set($origin = $input.params(\"origin\")) #end\n#if($origin.matches(\".*\")) #set($context.responseOverride.header.Access-Control-Allow-Origin = $origin) #end"
402+
"application/json": "#set($origin = $input.params(\"Origin\"))\n#if($origin == \"\") #set($origin = $input.params(\"origin\")) #end\n#if($origin.matches(\".+\")) #set($context.responseOverride.header.Access-Control-Allow-Origin = $origin) #end"
368403
}
369404
}
370405
]
371406
},
372-
"ResourceId": {
373-
"Ref": "ApiGatewayResourceItemItemidVar"
374-
},
375-
"RestApiId": {
376-
"Ref": "ApiGatewayRestApi"
377-
}
378-
}
379-
},
380-
"ApiGatewayMethodItemGet": {
381-
"Type": "AWS::ApiGateway::Method",
382-
"Properties": {
383-
"HttpMethod": "GET",
384-
"RequestParameters": {},
385407
"ResourceId": {
386408
"Ref": "ApiGatewayResourceItem"
387409
},
388410
"RestApiId": {
389411
"Ref": "ApiGatewayRestApi"
390-
},
391-
"ApiKeyRequired": false,
392-
"AuthorizationType": "NONE",
393-
"Integration": {
394-
"IntegrationHttpMethod": "POST",
395-
"Type": "AWS_PROXY",
396-
"Uri": {
397-
"Fn::Join": [
398-
"",
399-
[
400-
"arn:",
401-
{
402-
"Ref": "AWS::Partition"
403-
},
404-
":apigateway:",
405-
{
406-
"Ref": "AWS::Region"
407-
},
408-
":lambda:path/2015-03-31/functions/",
409-
{
410-
"Fn::GetAtt": [
411-
"GetItemsLambdaFunction",
412-
"Arn"
413-
]
414-
},
415-
"/invocations"
416-
]
417-
]
418-
}
419-
},
420-
"MethodResponses": []
412+
}
421413
}
422414
},
423415
"ApiGatewayMethodItemItemidVarGet": {
@@ -592,7 +584,7 @@
592584
"MethodResponses": []
593585
}
594586
},
595-
"ApiGatewayDeployment1578327561025": {
587+
"ApiGatewayDeployment1617033986619": {
596588
"Type": "AWS::ApiGateway::Deployment",
597589
"Properties": {
598590
"RestApiId": {
@@ -601,9 +593,8 @@
601593
"StageName": "dev"
602594
},
603595
"DependsOn": [
604-
"ApiGatewayMethodItemOptions",
605596
"ApiGatewayMethodItemItemidVarOptions",
606-
"ApiGatewayMethodItemGet",
597+
"ApiGatewayMethodItemOptions",
607598
"ApiGatewayMethodItemItemidVarGet",
608599
"ApiGatewayMethodItemPost",
609600
"ApiGatewayMethodItemItemidVarPost",
@@ -753,19 +744,19 @@
753744
"GetItemsLambdaFunctionQualifiedArn": {
754745
"Description": "Current Lambda function version",
755746
"Value": {
756-
"Ref": "GetItemsLambdaVersion0FdbsMpyGuJGkKPLMcXz2O5Fr6A6PAjphkZd9wRWqLs"
747+
"Ref": "GetItemsLambdaVersionjYYW7X8gqUHuD34wTZmIV6TNxI7OeAKAwazJ5PGBpM"
757748
}
758749
},
759750
"UpdateItemsLambdaFunctionQualifiedArn": {
760751
"Description": "Current Lambda function version",
761752
"Value": {
762-
"Ref": "UpdateItemsLambdaVersionTayhisxd9gbffpM8BhEkLl3y2PpIgnLCT1tTmLvTNc"
753+
"Ref": "UpdateItemsLambdaVersions6tcDejjJko6UQQ4aRF4DGweb0oLvV7s6OCVeMCVk"
763754
}
764755
},
765756
"DeleteItemsLambdaFunctionQualifiedArn": {
766757
"Description": "Current Lambda function version",
767758
"Value": {
768-
"Ref": "DeleteItemsLambdaVersionstQHAgwZsjbq0blNOuxbWh7M1sPoPdkGEjJUqQNx9w"
759+
"Ref": "DeleteItemsLambdaVersionZAG3AryC7HWe11S5T6bykH2MwzO5ymRkGYbnEEC5k"
769760
}
770761
},
771762
"ServiceEndpoint": {
Binary file not shown.

0 commit comments

Comments
 (0)