Skip to content

Commit

Permalink
AWSLambda: Make ListFunctions work for JS SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Feb 16, 2025
1 parent 8ebfa28 commit 10c841d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions moto/core/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def _get_method_urls(service_name: str, region: str) -> Dict[str, Dict[str, str]
_method = op_model.http["method"]
request_uri = op_model.http["requestUri"]
if service_name == "route53" and request_uri.endswith("/rrset/"):
# Terraform 5.50 made a request to /rrset/
# Terraform 5.51+ makes a request to /rrset - so we have to intercept both variants
request_uri += "?"
if service_name == "lambda" and request_uri.endswith("/functions/"):
# AWS JS SDK behaves differently from other SDK's, does not send a trailing slash
request_uri += "?"
uri_regexp = BaseResponse.uri_to_regexp(request_uri)
method_urls[_method][uri_regexp] = op_model.name
Expand Down
8 changes: 8 additions & 0 deletions other_langs/tests_js/lambda.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LambdaClient, ListFunctionsCommand } from '@aws-sdk/client-lambda'

process.env['AWS_ACCESS_KEY_ID'] = 'test'
process.env['AWS_SECRET_ACCESS_KEY'] = 'test'

const client_ = new LambdaClient({ endpoint: 'http://localhost:5000'});

await client_.send(new ListFunctionsCommand());
7 changes: 4 additions & 3 deletions other_langs/tests_js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"@aws-sdk/client-ec2": "^3.32.0",
"@aws-sdk/client-rds": "^3.32.0",
"@aws-sdk/client-s3": "^3.32.0"
"@aws-sdk/client-ec2": "^3.749.0",
"@aws-sdk/client-lambda": "^3.749.0",
"@aws-sdk/client-rds": "^3.749.0",
"@aws-sdk/client-s3": "^3.749.0"
},
"type": "module",
"scripts": {
Expand Down

0 comments on commit 10c841d

Please sign in to comment.