bln_dev
bln_dev

Reputation: 2421

AWS: redirection to Lambda function doesn't work from CloudFront Distribution

I use a Lambda function to resize images when requested on-the-fly by this tutorial.

The general flow is this:

Everything works fine when accessing the bucket with its endpoint URL directly. This endpoint URL is:

http://mybucket.s3-website.eu-central-1.amazonaws.com

However, when we now access the resources via the CloudFront distribution URL the redirect doesn't work. The CloudFront distribution is correctly set up. E.g. if we request an existing resource via the distribution URL the resource is delivered. But if we request a not existing resource the redirect is not triggered. If I check the origin settings of the CloudFront distribution I see that the Origin Domain Name is set to

mybucket.s3.amazonaws.com

So, no s3-website and no region!

Q1: Is the missing region the problem why the redirection rules of the bucket are not considered?

I wonder because the Origin Domain Name is selected by a dropdown and there is no region in the suggested buckets. However, I could edit the Origin Domain Name but as this a production system I do not want to mess up the configs.

Q2: what is the suggested setting to use the redirection rules of the Bucket website in combination with a CloudFront distribution?

http://wirvonhier.s3-website.eu-central-1.amazonaws.com

Upvotes: 1

Views: 901

Answers (1)

bln_dev
bln_dev

Reputation: 2421

According to here this and this document you need to ignore the dropdown and insert the correct endpoint manually in order to make the redirects available to the CloudFront distribution. However, an official reference would be desired.

Upvotes: 1

Related Questions