1# Example 2 3This example demonstrates how you can use the AWS SDK for Go V2's Amazon S3 client 4to use AWS PrivateLink for Amazon S3. 5 6# Usage 7 8## How to build vpc endpoint url 9 10To access S3 bucket data using the s3 interface endpoints, prefix the vpc 11endpoint with `bucket`. For eg, use endpoint url as `https://bucket.vpce-0xxxxxxx-xxx8xxg.s3.us-west-2.vpce.amazonaws.com` 12to access S3 bucket data via the associated vpc endpoint. 13 14To access S3 access point data using the s3 interface endpoints, prefix the vpc 15endpoint with `accesspoint`. For eg, use endpoint url as `https://accesspoint.vpce-0xxxxxxx-xxxx8xxg.s3.us-west-2.vpce.amazonaws.com` 16to access S3 access point data via the associated vpc endpoint. 17 18To work with S3 control using the s3 interface endpoints, prefix the vpc endpoint 19with `control`. For eg, use endpoint url as `https://control.vpce-0xxxxxxx-xxx8xxg.s3.us-west-2.vpce.amazonaws.com` 20to use S3 Control operations with the associated vpc endpoint. 21 22## How to use the built vpc endpoint url 23 24Provide the vpc endpoint url (built as per instructions above) to the SDK by providing a custom endpoint resolver on 25client config or as a part of request options. The VPC endpoint url should be provided as a custom endpoint, 26which means the Endpoint source should be set as EndpointSourceCustom. 27 28You can use client's `EndpointResolverFromURL` utility which by default sets the Endpoint source as Custom source. 29Note that the SDK may mutate the vpc endpoint as per the input provided to work with ARNs, unless you explicitly set 30HostNameImmutable property for the endpoint. 31 32The example will create s3 client's that use appropriate vpc endpoint url. The example 33will then create a bucket of the name provided in code. Replace the value of 34the `accountID` const with the account ID for your AWS account. The 35`vpcBucketEndpointUrl`, `vpcAccesspointEndpoint`, `vpcControlEndpoint`, `bucket`, 36`keyName`, and `accessPoint` const variables need to be updated to match the name 37of the appropriate vpc endpoint, Bucket, Object Key, and Access Point that will be 38created by the example. 39 40```sh 41 AWS_REGION=<region> go run usingPrivateLink.go 42 ``` 43