配置 Boto3 endpoint_url
原文由 Alex O'Callaghan 于 发布,订阅该博客
通过环境变量配置 Boto3 endpoint_url 是在 boto3 1.28.0 中新增的一项期待已久的功能。
在开发使用 AWS 服务的应用时,常见的做法是在开发环境中使用本地服务,例如 LocalStack 提供的服务。
AWS SDK 现在支持通过 AWS_ENDPOINT_URL 和 AWS_ENDPOINT_URL_<SERVICE> 环境变量配置服务特定的端点。
使用以下环境变量:
AWS_ENDPOINT_URL=http://localhost:4566
AWS_ENDPOINT_URL_S3=http://localhost:4567
Boto3 将使用这些值来设置 endpoint_url:
import boto3
db = boto3.client("dynamodb") # endpoint_url=http://localhost:4566
s3 = boto3.client("s3") # endpoint_url=http://localhost:4567随机一篇博客
评论
登录后参与讨论