1
头图

image.png

Summary

Amazon Cloud Technology officially released Amazon PrivateLink for Amazon S3 in February 2021. Amazon PrivateLink Amazon Simple Storage Service (S3) and on-premises resources using a private IP in a virtual network. With this feature, you can now use Virtual Private Cloud to directly access Amazon S3 as a private endpoint in a secure virtual network. This extends the functionality of existing gateway endpoints by allowing you to access Amazon S3 using a private IP address. API and HTTPS requests to Amazon S3 from on-premises applications are automatically directed through interface endpoints that connect to Amazon S3 in a secure and private manner via PrivateLink.

The solution described in this document is to achieve cross-region private access to Amazon S3 by utilizing cross-region VPC peering connections and Amazon S3 interface endpoints. Customers can privately access Amazon S3 from on-premises applications via secure connections provided Amazon Direct Connect or Amazon VPN , depending on their needs.

image.png

📢 To learn more about the latest technology releases and practical innovations of Amazon Cloud Technology, please pay attention to the 2021 Amazon Cloud Technology China Summit! Click on the picture to sign up~ For more exciting content, please look forward to the 8.19-20 Beijing and 9.15 Shenzhen chapters!

Service Introduction

Back in 2015, Amazon S3 was the first service to support adding VPC endpoints ; provides a secure connection to Amazon S3 through a VPC gateway endpoint without requiring a gateway or NAT instance. The principle is to create a route to the Amazon S3 service in the specified routing table, each subnet associated with the routing table can access the endpoint, and then route the traffic from these subnet instances to the Amazon S3 service through the endpoint. . In the following diagram, instances in subnet 2 can access Amazon S3 through the gateway endpoint.

image.png

This new flexibility is well received by customers, but it also has its limitations – private access to Amazon S3 across regions and on-premises datacenters is not supported, which the newly introduced Amazon S3 interface endpoints can do by choosing , create an Amazon S3 interface endpoint with an ENI that assigns a private IP, enabling a secure connection to Amazon S3. In-VPC applications, or Amazon Direct Connect or Amazon VPN , can privately access Amazon S3 through the interface endpoint. Interface endpoints simplify your network architecture by eliminating the need to configure firewall rules or internet gateways when connecting to Amazon S3 from on-premises applications.

image.png

Comparison of two Amazon S3 endpoints:

image.png

overall architecture of the demo environment

  image.png

VPC setup for the demo environment:

image.png

Notice:

  • The CIDR blocks of 2 VPCs connected by VPC peering cannot overlap
  • Using private DNS (Amazon PrivateLink) with an interface VPC endpoint, you must enableDnsHostnames
  • and enableDnsSupport property set to true
  • DNS resolution needs to be enabled in both VPC peering connections
  • The security group for the interface endpoint must allow inbound HTTPS (port 443) traffic

Demonstration environment

4.1 Create a demo VPC environment

Create a VPC with a public subnet and a private subnet in each region through the wizard of the VPC Console, and create an Amazon S3 bucket in the cn-northwest-1 region (the specific steps are omitted). Below is a screenshot from my demo environment:

image.png

cn-north-1 regional VPC and subnet

image.png

cn-northwest-1 regional VPC and subnet

image.png

Enable DNS hostnames and DNS resolution in both VPCs:

image.png

Amazon S3 bucket in the cn-northwest-1 region

  

4.2 Establish a cross-region VPC

Create a peering connection between the VPCs in the two regions and update the routing table (the specific steps are omitted). The following is a screenshot of my demo environment:

image.png

VPC peering connection

image.png

Enable DNS resolution in both VPC peering connections

image.png

cn-north-1 area routing table

image.png

cn-northwest-1 regional routing table

4.3 Verifying cross-region VPC

Create an EC2 instance in each of the public subnet and private subnet of cn-north-1. The EC2 in the public subnet is used as a springboard to connect to the EC2 in the private subnet. At the same time, create an EC2 instance on the private subnet of cn-northwest-1.

image.png

cn-north-1 region EC2

image.png

cn-northwest-1 region EC2

image.png

EC2 Security Group Inbound

image.png

EC2 Security Group Outbound

With the help of the EC2 jumper in the public subnet, verify that the EC2 (IP: 172.31.30.22) in the private subnet of cn-north-1 has successfully SSHed to the EC2 instance (IP: 10.10.1.94) of cn-northwest-1.

image.png

4.4 Create Amazon S3 interface endpoint

First, in order to ensure that Amazon Cloud Technology command line tools (such as Amazon CLI) can make requests from resources in the VPC to Amazon Cloud Technology services over HTTPS, the security group of the interface endpoint must allow inbound HTTPS (port 443) traffic, so in cn The -northwest-1 region creates a security group with the following inbound rules:

image.png

Create an Amazon S3 interface endpoint in the VPC in the cn-northwest-1 region, and associate the corresponding VPC and subnet to implement cross-region private access to Amazon S3.

image.png

Next, associate the security group created earlier with the interface endpoint, and then create the interface endpoint for Amazon S3.

image.png

Once created, two types of DNS for Amazon S3 interface endpoints are generated:

  • Regional DNS – includes the unique VPC endpoint ID, service identifier, Amazon region and amazonaws.com, in this instance vpce-0257c85882d96cc95-vj9syim9.s3.cn-northwest-1.vpce.amazonaws.com.cn
  • Zone DNS – includes availability zones, such as vpce-0257c85882d96cc95-vj9syim9-cn-northwest-1a.s3.cn-northwest-1.vpce.amazonaws.com.cn, customers use this type of DNS to specify availability zones and reduce Availability Zone Data Transfer Cost

image.png

Amazon S3 Interface Endpoint Create an Amazon Amazon S3 Interface Endpoint with an ENI that assigns a private IP in the subnet of your choice, enabling a secure connection to Amazon S3.

image.png 

4.5 Test Verification

First, create a role for the EC2 service in cn-north-1 and give Amazon S3 read and write permissions.

image.png

Assign the role of the created EC2 service to EC2 (IP: 172.31.30.22) in the private subnet of cn-north-1.

image.png

Verify that the Amazon s3 bucket of cn-northwest-1 cannot be directly accessed from EC2, because EC2 is in a private subnet and cannot access the public network to access Amazon S3 Endpoint. The command will hang until it times out.

Note: You need to upgrade the Amazon CLI to the latest version first.

image.png

Verify that EC2 in the private subnet of cn-north-1 can successfully access the Amazon s3 bucket located at cn-northwest-1 and upload files through the VPC peering connection and Amazon S3 interface endpoint DNS.

image.png

image.png

use recommended

The Amazon S3 interface endpoint and the previous gateway endpoint can coexist. It is recommended that applications in the VPC in this region secure Amazon S3 privately through the gateway endpoint, which will not incur additional charges. For other regions and customer data centers with interface endpoints, connect to Amazon S3 in a secure and private manner via Amazon PrivateLink. The recommended architecture is as follows:

image.png

For the local data center to access the DNS of the Amazon S3 interface endpoint, the Amazon Cloud Technology Global area can be combined with Route53 Resolver (refer to Document 1); the Amazon Cloud Technology China area can build a DNS Proxy to implement DNS resolution (refer to Document 2).

summary

This article introduces the use of Amazon S3's interface endpoints and cross-region VPC peering to achieve cross-region private access to Amazon S3, and network traffic is maintained on Amazon's network through Amazon PrivateLink. Customers can privately access Amazon S3 from on-premises applications via secure connections provided Amazon Direct Connect or Amazon VPN , depending on their needs. API and HTTPS requests from on-premises applications to Amazon S3 are automatically directed through interface endpoints that connect to Amazon S3 in a secure and private manner via PrivateLink.

Reference Document

Author of this article

image.png

Zhu

Amazon Cloud Technology Account Manager

Responsible for the structure and cost optimization, technical support and other work of enterprise-level customers. He is committed to AdTech and other industries. He has worked for IBM and has 15+ years of experience in product design, development/testing, and technical support.


亚马逊云开发者
2.9k 声望9.6k 粉丝

亚马逊云开发者社区是面向开发者交流与互动的平台。在这里,你可以分享和获取有关云计算、人工智能、IoT、区块链等相关技术和前沿知识,也可以与同行或爱好者们交流探讨,共同成长。