简体   繁体   English

通过 VPC 端点和 ALB 访问 AWS S3

[英]AWS S3 access through VPC endpoint and ALB

I have created a bucket in S3.我在 S3 中创建了一个存储桶。 I want to retrieve the documents using Java SDK from my local machine, not from EC2.我想使用 Java SDK 从我的本地计算机而不是 EC2 检索文档。 In order to access the local machine, I have created the VPC interface endpoint for S3 and ALB which routes to the VPC endpoint.为了访问本地机器,我为 S3 和 ALB 创建了 VPC 接口端点,该端点路由到 VPC 端点。

local machine -> ALB -> VPC endpoint -> S3本地机器 -> ALB -> VPC 端点 -> S3

I have added the ALB IP for the VPC endpoint DNS name along with the bucket name in the /etc/hosts.我在 /etc/hosts 中添加了 VPC 端点 DNS 名称的 ALB IP 名称以及存储桶名称。 The reason is, the S3 SDK endpoint URL will be [bucketname].[endpoint DNS name]原因是,S3 SDK 端点 URL 将是 [bucketname].[endpoint DNS name]

AmazonS3ClientBuilder.standard().withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(ENPOINT_URL, "eu-west-1")).withCredentials(awsCred).build();

upon executing above piece of code, I get执行上面的代码后,我得到

com.amazonaws.services.s3.model.AmazonS3Exception: The specified bucket does not exist (Service: Amazon S3; Status Code: 404; Error Code: NoSuchBucket; Request ID: M6ECW14CH0CK6SNK; S3 Extended Request ID: zlgF4fvV+KgebQUS7sIz3iyXtIlCf+kaXPJQqE3QRK+aTETMpRu/bsHkhlbXgs=; Proxy: null), S3 Extended Request ID: zlgF4fvV+KgebQUS7sIz3iyXtIlCf+kaXPJQqE3QRK+aTETMpRu/bsHkhlbXgs=

Could someone say what am missing here?有人可以说这里缺少什么吗?

Note: S3 shall be invoked directly without this approach but this is for POC purposes.注意:S3 应直接调用,无需此方法,但这是出于 POC 目的。

It works after updating the SDK version to 2.17.281 (latest as of now).它在将 SDK 版本更新到 2.17.281(截至目前最新)后工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM