question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

access denied on CloudFront website after setting bucketRegion

See original GitHub issue

Describe the bug When I set the bucketRegion to ap-southeast-2, I got an access denied page when I visited the CloudFront URL.

To Reproduce Steps to reproduce the behavior:

  1. Run npx create-next-app and change directory into the project folder
  2. Add serverless.yml to the project folder
  3. Run sls
  4. Wait for the AWS CloudFront console to show the new distribution has finished deploying
  5. Visit appUrl printed in terminal
  6. Web browser shows a CloudFront access denied error page

serverless.yml contents:

nextTest:
  component: serverless-next.js
  inputs:
    bucketRegion: ap-southeast-2

Expected behavior The NextJS sample website should appear in the browser.

Work around I used the AWS CloudFront console to change the distribution origin from:

<bucket-name>.s3.amazonaws.com

to:

<bucket-name>.s3.ap-southeast-2.amazonaws.com

then waited for the distribution to deploy, and the sample website now comes up fine in the browser. The AWS docs also say this error clears by itself if you wait 24 hours after creating a new distribution pointing to an S3 bucket in a custom region.

The serverless-next.js README says 307 redirects may happen when you use a bucket with a different region, but the README doesn’t say anything about access denied errors happening in the first 24 hours.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yellowtailfancommented, Jul 30, 2020

Great, that does seem to be including the region in the CloudFront origin now, thanks!

0reactions
danielcondemarincommented, Jul 30, 2020

@yellowtailfan this should be fixed in @sls-next/serverless-component@1.16.0-alpha.0. Could you try that? I’ll look at promoting it to stable this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve Access Denied errors from a CloudFront distribution ...
1. Open your S3 bucket from the Amazon S3 console. · 2. Choose the Permissions tab. · 3. Choose Bucket Policy. · 4....
Read more >
Amazon Cloudfront with S3. Access Denied - Server Fault
keep static website hosting disabled on the S3 bucket; keep the Cloudfront distribution origin as an S3 ID; set "Restrict Bucket Access" to...
Read more >
AWS CloudFront access denied to S3 bucket - Stack Overflow
If you want to allow anyone to access the objects in your Amazon S3 bucket using CloudFront URLs, you must grant public read...
Read more >
Resolving AWS CloudFront Access Denied Errors
Use a private bucket. Don't enable static website hosting on the bucket (the Distribution will have a S3 Origin). Use an Origin Access...
Read more >
Access Denied error when accessing Cloudfront url image link
Confirm that the objects in the bucket are not encrypted by AWS KMS 2. Confirm that there is no explicit "Deny" in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found