si vous voulez la liberté complète/une transparence totale dans Lambda, alors vous voudrez peut-être examiner l'intégration Lambda proxy
import json
def endpoint(event, context):
# With the Lambda proxy integration, API Gateway maps the entire client request to the
# input event parameter of the backend Lambda function as follows:
# {
# "resource": "Resource path",
# "path": "Path parameter",
# "httpMethod": "Incoming request's method name"
# "headers": {Incoming request headers}
# "queryStringParameters": {query string parameters }
# "pathParameters": {path parameters}
# "stageVariables": {Applicable stage variables}
# "requestContext": {Request context, including authorizer-returned key-value pairs}
# "body": "A JSON string of the request payload."
# "isBase64Encoded": "A boolean flag to indicate if the applicable request payload is Base64-encode"
# }
body = {}
body["event"] = event
# With the Lambda proxy integration, API Gateway requires the backend Lambda function
# to return output according to the following JSON format:
# {
# "isBase64Encoded": true|false,
# "statusCode": httpStatusCode,
# "headers": { "headerName": "headerValue", ... },
# "body": "..."
# }
response = {
"statusCode": 200,
"isBase64Encoded": False,
"headers": {"x-test-header" : "foobar"},
"body": json.dumps(body),
}
return response
et dans le modèle
"paths": {
"/{proxy+}": {
"x-amazon-apigateway-any-method": {
"parameters": [{
"name": "proxy",
"in": "path",
"required": true,
"type": "string"
}],
"produces": ["application/json"],
"responses": {},
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:xxxx:function:yyy/invocations",
"passthroughBehavior": "when_no_match",
"httpMethod": "POST",
"cacheNamespace": "57w2aw",
"cacheKeyParameters": [
"method.request.path.proxy"
],
"contentHandling": "CONVERT_TO_TEXT",
"type": "aws_proxy"
}
}
}
}
Je pense que cette question a été répondu ici avant: https://stackoverflow.com/questions/34386869/how-do-i-pass-arguments-to-aws-lambda-functions-using-get-requests –
Merci, oui, c'est utile. Mais j'espérais qu'il y aurait un moyen plus facile dans serverless.yml –