AWS re:Post Knowledge Center Feedback Survey
Help us improve the AWS re:Post Knowledge Center by sharing your feedback in a brief survey. Your input can influence how we create and update our content to better support your AWS journey.
我想将 Amazon DynamoDB 与我的 AWS Lambda 实例集成到 Amazon Virtual Private Cloud (Amazon VPC) 中。
先决条件:
完成以下步骤:
import json import boto3 client = boto3.client('dynamodb') def lambda_handler(event, context): response = client.get_item( TableName='Music', Key={ 'Artist': { 'S': 'No One You Know', }, 'SongTitle': { 'S': 'Call Me Today', }, } ) print(response) return { 'statusCode': 200, 'body': json.dumps('Success!') }
要对连接到 VPC 的 Lambda 函数进行故障排除,请采取以下操作:
从 Lambda 函数中移除与公有子网的所有连接。如果您连接到公有子网,则流量会尝试流经公有子网,并可能导致间歇性超时问题。
请确保您的 DynamoDB 网关端点配置正确。
更新与您的 Lambda 函数关联的私有子网,以通过您的 DynamoDB VPC 网关端点进行路由。这些端点具有 AWS 托管式前缀列表,可简化 Lambda 和 DynamoDB 之间安全组设置的配置。 私有子网路由表的示例:
Route Table: rtb-12345 Destination Gateway Status 10.0.0.0/16 local active pl-1234 vpce-1234 active
更新您的 Lambda 安全组规则以允许所有流量。
使用控制台创建 Lambda 函数
使用 Amazon VPC 端点来访问 DynamoDB
网络和 VPC 配置