验证 EC2 中的 boto3 是否正在使用 VPC 端点连接到 S3?

问题描述 投票:0回答:1

如何验证 EC2 中的

boto3.client('s3')
是否正在使用 VPC 端点?

在AWS中,我创建了一个VPC端点(服务= s3,类型=网关)。据我了解,boto 会自动选择它的

client(endpoint_url)
。我正在摄取 TB 级的数据,因此我不想在从 EC2 写入到 S3 时收取出口费用。

桌面

>>> import boto3
>>> conn = boto3.client('s3')
>>> conn._endpoint

"s3(https://s3.amazonaws.com)"

AWS 批处理作业 - VPC 内的 Fargate

我想在这里了解更多信息。它是否指向我的 VPC 终端节点 ID/ARN?

>>> import boto3
>>> conn = boto3.client('s3')
>>> conn._endpoint

"s3(https://s3.amazonaws.com)"

这里,boto3 确认我的 VPC 端点的存在

>>> from pprint import pprint
>>> import boto3

>>> conn = boto3.client('ec2')    #<-- note 'ec2' not 's3'
>>> resp = conn.c.describe_vpc_endpoints()
>>> pprint(resp['VpcEndpoints'])
amazon-web-services amazon-s3 boto3
1个回答
0
投票

我能想到的最简单的方法是使用桶策略。您可以限制存储桶对特定终端节点的访问。如果应用存储桶策略后您的请求仍然有效,则意味着您的请求正在通过 VPC 终端节点。

© www.soinside.com 2019 - 2024. All rights reserved.