I am trying to load a file in an Amazon S3 bucket using a VPC endpoint. I can upload the file using this code:
TransferUtility utility = new TransferUtility(awsAccessKey, awsSecretKey, Amazon.RegionEndpoint.USWest1);
TransferUtilityUploadRequest request = new TransferUtilityUploadRequest();
request.BucketName = "test" @"/" S3Path;
request.InputStream = st;
utility.Upload(request);
I was asked to use the VPC endpoint to get the S3 client and then upload the bucket.
After searching, I found this in Java:
String endpoint = Toolkit.getParameter("s3-vpc-endpoint");
S3Client s3Client = S3Client.builder().region(Region.US_WEST_2)
.endpointOverride(URI.create(endpoint))
.build();
What is the equivalent in C#?
CodePudding user response:
A gateway endpoint is a gateway that is a target for a route in your route table used for traffic destined to either Amazon S3 or DynamoDB.
Gateway endpoints work at the infrastructure level so there is no need to do anything within applications themselves.
As per docs:
If you've already set up access to your Amazon S3 resources from your VPC, you can continue to use Amazon S3 DNS names to access those resources after you've set up an endpoint.
The code you're referencing probably is referring to an Amazon S3 endpoint which also includes the bucket name e.g. mybucket.s3.eu-west-1.amazonaws.com
.
As you're specifying the region and bucket name already in your code, you are good to go.