Navin Nagpal
Navin Nagpal

Reputation: 640

CloudFront custom file location

So this is my first time with AWS and server setup stuff. I have an S3 configured as well as CloudFront on AWS. Since the origin of my CloudFront is set to my S3, the files on S3 I believe will be retrieved say as follows via CloudFront

S3 - https://s3-ap-southeast-1.amazonaws.com/testbucket/uploads/logo/UfB7wDrn9A5r.jpg

CloudFront - https://randomstring.cloudfront.net/uploads/logo/UfB7wDrn9A5r.jpg

However what I would like to achieve - may seem a long shot - is my CloudFront path for my image to be something like -

https://randomstring.cloudfront.net/UfB7wDrn9A5r.jpg

So basically irrespective of what the path of the file is in S3, I would want the file to be present only at the root in CloudFront. Is this even remotely possible ?

Upvotes: 1

Views: 277

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179124

irrespective of what the path of the file is in S3

Irrespective, no. This isn't something you can do out of the box with S3 and/or CloudFront.

It is possible to collapse a single path in the bucket, such that the content of /uploads/logo would appear in the root of the CloudFront distribution, but all files not in /uploads/logo would be inaccessible through CloudFront.

This is done by setting the Origin Path in CloudFront.

If you used /uploads as the origin path, then the files in /uploads/logo/* would appear as just /logo/* in CloudFront, but it doesn't sound like that is your intended outcome.

Anything else would require an intermediate system between CloudFront and S3 to "hunt" for the desired resource, which would be inefficient and time-consuming, not to mention the possibility of filename collisions.

Upvotes: 2

Related Questions