How to redirect a request to an existing S3 object having the `s3.amazonaws.com` urls

0

I had created a bucket to store customer images on S3 quite some time ago. Our customer emails contain s3 urls of the format

https://s3.amazonaws.com/<bucketName>/<fileName>

so that the customers can download their images if needed. Im planning to move all these objects to a new bucket. But i'm worried that the existing urls sent out in the emails will no longer work. So i've been searching for a way to redirect requests that reference any object in my old bucket.

So far i've only seen solutions for objects that are referenced using the static web endpoint of the bucket (urls that look like the one below).

http://mybucket.s3-website-us-east-1.amazonaws.com/image.png

I was wondering if there is a way to redirect requests that reference objects through urls like the one mentioned below.

https://s3.amazonaws.com/mybucket/image.png.

Also, static website hosting is not switched on for this bucket in case you are wondering.

suhail
질문됨 한 달 전134회 조회
2개 답변
1

S3 buckets themselves don't offer built-in redirection capabilities. Below are two common approaches to achieve redirection for S3 objects with s3.amazonaws.com URLs:

Using Amazon CloudFront: CloudFront is a content delivery network (CDN) service offered by AWS. You can create a CloudFront distribution with your S3 bucket as the origin. CloudFront allows configuring behaviors within the distribution to set redirects for specific request paths.

Using Amazon Route 53: Route 53 is a DNS (Domain Name System) service by AWS. You can set up a Route 53 hosted zone for your custom domain and configure it to point to the S3 bucket website endpoint. Additionally, you can create a redirect rule within Route 53 to redirect requests for specific paths to your desired destination.

Hope it helps to an extent.

profile pictureAWS
akad
답변함 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전
  • The CloudFront approach sounds good. Will try this solution out asap and share my findings here

1

Hi, I don't think there is a simpler way of doing the redirects without enabling S3 static website hosting on the S3 bucket. You may look into using CloudFront with Lambda@Edge to handle redirects to see if it achieves your use case.

https://aws.amazon.com/blogs/networking-and-content-delivery/handling-redirectsedge-part1/

psp
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠