【发布时间】:2019-07-16 23:38:01
【问题描述】:
问题
我在 AWS 上部署的 Lambda 之前只使用了服务名称的 boto3 客户端/资源,但是在 Localstack 中部署的 Lambda 仅在 region_name、aws_access_key_id、aws_secret_key_id 和 endpoint_url 时工作。
如何消除对这个的需求?
我的尝试
我尝试在没有额外参数的情况下在 Localstack 中部署 Lambda,但出现以下错误:
Exception: ('Unable to get handler function from lambda code.', NoRegionError('You must specify a region.',))
和
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the Scan operation: The security token included in the request is invalid.
我想要什么
理想情况(就像我目前在 AWS 上的 Lambda 一样):
dynamodb = boto3.client('dynamodb')
当前的解决方法(部署到 Localstack 时):
dynamodb = boto3.client('dynamodb', region_name='eu-west-2',
aws_access_key_id="", aws_secret_access_key="",
endpoint_url='http://localhost:4569')
【问题讨论】:
标签: python-3.x amazon-web-services aws-lambda boto3 localstack