-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add TimeoutInMillis Property to API Event Source (#3310)
- Loading branch information
Showing
13 changed files
with
734 additions
and
13 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
integration/combination/test_function_with_implicit_api_with_timeout.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from unittest.case import skipIf | ||
|
||
from integration.config.service_names import REST_API | ||
from integration.helpers.base_test import BaseTest | ||
from integration.helpers.resource import current_region_does_not_support | ||
|
||
|
||
@skipIf(current_region_does_not_support([REST_API]), "REST API is not supported in this testing region") | ||
class TestFunctionWithImplicitApiWithTimeout(BaseTest): | ||
def test_function_with_implicit_api_with_timeout(self): | ||
self.create_and_verify_stack("combination/function_with_implicit_api_with_timeout") | ||
|
||
# verify that TimeoutInMillis is set to expected value in the integration | ||
expected_timeout = 5000 | ||
apigw_client = self.client_provider.api_client | ||
rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi") | ||
resources = apigw_client.get_resources(restApiId=rest_api_id)["items"] | ||
|
||
method = apigw_client.get_method(restApiId=rest_api_id, resourceId=resources[0]["id"], httpMethod="GET") | ||
method_integration = method["methodIntegration"] | ||
self.assertEqual(method_integration["timeoutInMillis"], expected_timeout) |
26 changes: 26 additions & 0 deletions
26
integration/resources/expected/combination/function_with_implicit_api_with_timeout.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ | ||
"LogicalResourceId": "MyLambdaFunctionApiEventPermissionProd", | ||
"ResourceType": "AWS::Lambda::Permission" | ||
}, | ||
{ | ||
"LogicalResourceId": "MyLambdaFunctionRole", | ||
"ResourceType": "AWS::IAM::Role" | ||
}, | ||
{ | ||
"LogicalResourceId": "MyLambdaFunction", | ||
"ResourceType": "AWS::Lambda::Function" | ||
}, | ||
{ | ||
"LogicalResourceId": "ServerlessRestApiDeployment", | ||
"ResourceType": "AWS::ApiGateway::Deployment" | ||
}, | ||
{ | ||
"LogicalResourceId": "ServerlessRestApiProdStage", | ||
"ResourceType": "AWS::ApiGateway::Stage" | ||
}, | ||
{ | ||
"LogicalResourceId": "ServerlessRestApi", | ||
"ResourceType": "AWS::ApiGateway::RestApi" | ||
} | ||
] |
23 changes: 23 additions & 0 deletions
23
integration/resources/templates/combination/function_with_implicit_api_with_timeout.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: A template to test timeout support for implicit APIs. | ||
|
||
Resources: | ||
MyLambdaFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs16.x | ||
MemorySize: 128 | ||
Timeout: 3 | ||
InlineCode: | | ||
exports.handler = async () => ‘Hello World!' | ||
Events: | ||
ApiEvent: | ||
Type: Api | ||
Properties: | ||
Path: /hello | ||
Method: get | ||
TimeoutInMillis: 5000 | ||
|
||
Metadata: | ||
SamTransformTest: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Resources: | ||
RestApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/todo_list.zip | ||
Handler: index.restapi | ||
Runtime: nodejs12.x | ||
Policies: AmazonDynamoDBFullAccess | ||
Events: | ||
AddItem: | ||
Type: Api | ||
Properties: | ||
Path: /add | ||
Method: post | ||
TimeoutInMillis: 5000 | ||
CompleteItem: | ||
Type: Api | ||
Properties: | ||
Path: /complete | ||
Method: POST | ||
TimeoutInMillis: 5000 | ||
GetList: | ||
Type: Api | ||
Properties: | ||
Path: /getlist | ||
Method: get | ||
TimeoutInMillis: 10000 |
Oops, something went wrong.