【发布时间】:2020-08-05 00:14:14
【问题描述】:
我正在研究使用 AWS API 网关和 AWS Lambda 将数据发布到 DynamoDB 的 API。问题是当我使用测试场景时工作正常,但在 Postman 或任何其他外部 AWS API 服务中不一样。
import boto3
import uuid
def lambda_handler(event, context):
# this will create dynamodb resource object and
# here dynamodb is resource name
client = boto3.resource('dynamodb')
title = event['title']
#generte UUID
recordId = str(uuid.uuid4())
# this will search for dynamoDB table
# your table name may be different
table = client.Table("smsapi")
print(table.table_status)
#Creating an Item with a unique id and with the passed title
table.put_item(
Item={
'id' : recordId,
'title' : title
}
)
return recordId
在 Postman 中我收到 502 Bad gateway
【问题讨论】:
标签: python-3.x amazon-web-services aws-lambda aws-api-gateway