| 1 |
.. Copyright 2010-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 |
|
| 3 |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 |
| 4 |
International License (the "License"). You may not use this file except in compliance with the |
| 5 |
License. A copy of the License is located at http://creativecommons.org/licenses/by-nc-sa/4.0/. |
| 6 |
|
| 7 |
This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
| 8 |
either express or implied. See the License for the specific language governing permissions and |
| 9 |
limitations under the License. |
| 10 |
|
| 11 |
################## |
| 12 |
AWS PrivateLink for Amazon S3 |
| 13 |
################## |
| 14 |
|
| 15 |
This section demonstrates how to configure an S3 client to use an interface |
| 16 |
VPC endpoint. |
| 17 |
|
| 18 |
|
| 19 |
Configuring the client endpoint URL |
| 20 |
================================ |
| 21 |
|
| 22 |
When configuring an S3 client to use an interface VPC endpoint it's important |
| 23 |
to note that only the resource type specified in the endpoint can be addressed |
| 24 |
using that client. An exception is Amazon S3 buckets, which can be addressed |
| 25 |
using `using an access point alias |
| 26 |
<https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-naming.html#access-points-alias>`_ |
| 27 |
on the bucket endpoint as the bucket name. |
| 28 |
|
| 29 |
The following example configures an S3 client to access S3 buckets via an |
| 30 |
interface VPC endpoint. This client cannot be used to address S3 access points |
| 31 |
unless you `use an access point alias |
| 32 |
<https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-naming.html#access-points-alias>`_. |
| 33 |
|
| 34 |
.. code-block:: python |
| 35 |
|
| 36 |
import boto3 |
| 37 |
|
| 38 |
s3_client = boto3.client( |
| 39 |
service_name='s3', |
| 40 |
endpoint_url='https://bucket.vpce-abc123-abcdefgh.s3.us-east-1.vpce.amazonaws.com' |
| 41 |
) |
| 42 |
|
| 43 |
The following example configures an S3 client to access S3 access points via an |
| 44 |
interface VPC endpoint. This client cannot be used to address S3 buckets. |
| 45 |
|
| 46 |
.. code-block:: python |
| 47 |
|
| 48 |
import boto3 |
| 49 |
|
| 50 |
s3_client = boto3.client( |
| 51 |
service_name='s3', |
| 52 |
endpoint_url='https://accesspoint.vpce-abc123-abcdefgh.s3.us-east-1.vpce.amazonaws.com' |
| 53 |
) |
| 54 |
|
| 55 |
The following example configures an S3 Control client to use an interface VPC |
| 56 |
endpoint. |
| 57 |
|
| 58 |
.. code-block:: python |
| 59 |
|
| 60 |
import boto3 |
| 61 |
|
| 62 |
control_client = boto3.client( |
| 63 |
service_name='s3control', |
| 64 |
endpoint_url='https://control.vpce-abc123-abcdefgh.s3.us-east-1.vpce.amazonaws.com' |
| 65 |
) |
| 66 |
|
| 67 |
The following example accesses an object in an Amazon S3 bucket using an access point alias. |
| 68 |
|
| 69 |
.. code-block:: python |
| 70 |
|
| 71 |
import boto3 |
| 72 |
|
| 73 |
s3_client = boto3.client( |
| 74 |
service_name='s3', |
| 75 |
endpoint_url = 'https://bucket.vpce-abc123-abcdefgh.s3.us-east-1.vpce.amazonaws.com' |
| 76 |
) |
| 77 |
s3_client.get_object(Bucket='some-bucket-alias-s3alias', Key='file.txt') |