我有一个简单的Lambda函数,它位于以下端点下:
https://******.execute-api.eu-west-2.amazonaws.com/lambda/add?x=1&y=2
AWS Chalice 用于在这里添加简单的端点。
@app.route('/{exp}', methods=['GET'])
def add(exp):
app.log.debug("Received GET request...")
request = app.current_request
app.log.debug(app.current_request.json_body)
x = request.query_params['x']
y = request.query_params['y']
if exp == 'add':
app.log.debug("Received ADD command...")
result = int(x) + int(y)
return {'add': result}
基本上,它检查
path
是否等于add
并从query_params
中求和两个值。现在,我正在尝试在另一个lambda中调用此lambda。
我的问题是:
如何使用boto3 lambda客户端将
path
和query_params
传递给我的原始lambda函数?到目前为止,我尝试了什么:
我在
policy.json
文件中添加了两行,允许我调用原始函数。我在StackOverflow上看到了很多类似的问题,但大多数人将有效负载作为json传递。
@app.route('/')
def index():
lambda_client = boto3.client('lambda')
invoke_response = lambda_client.invoke(
FunctionName="function-name",
InvocationType="RequestResponse"
)
app.log.debug(invoke_response['Payload'].read())
感谢您的提前帮助!