简体   繁体   English

从 python 程序调用时未找到 Lambda function

[英]Lambda function not found while invoke it from python program

I have created lambda function and tried to invoke it from python program using boto3 API,its failing.我创建了 lambda function 并尝试使用 boto3 API 从 python 程序调用它,但失败了。

import boto3
client = boto3.client('lambda','us-east-1')
response = client.invoke(
    FunctionName='arn:aws:lambda:us-east-1:025631470700:function:app-test',
    InvocationType='Event',
    LogType='Tail',
    Payload='{"name": "David","status": "Active"}',
    Qualifier='1'
)

Traceback (most recent call last):
  File "/home/ssm-user/test.py", line 11, in <module>
    Qualifier='1'
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the Invoke operation: Function not found: arn:aws:lambda:us-east-1:025631470700:function:app-test:1

Did i miss anything?我错过了什么吗? Any thoughts, much appreciated任何想法,非常感谢

As the user Jens said in the comments, the FunctionName argument of the invoke() function is not the ARN of the lambda, it's its name.正如用户 Jens 在评论中所说, invoke() function 的FunctionName参数不是 lambda 的 ARN,而是它的名称。 Use this:用这个:

response = client.invoke(
    FunctionName='app-test',
    InvocationType='Event',
    LogType='Tail',
    Payload='{"name": "David","status": "Active"}',
    Qualifier='1'
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM