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.

[s3 + cloudfront] Allow cross-region references

See original GitHub issue

This sort of applies to both S3 and CloudFront; I was attempting to set up CloudFront distribution with origins in 2 different regions. When I refer to the bucket it is using the incorrect regional endpoint by assuming the bucket access endpoint should be the region of the stack/distribution and not the region of the bucket.

Reproduction Steps

    // This stack is deployed in us-east-1 so that we can generate ACM certs and actually consume them in cloudfront

    const sydBucket = s3.Bucket.fromBucketName(this, "sydBucket", "bucket-from-ap-southeast-2")
    const pdxBucket = s3.Bucket.fromBucketName(this, "pdxBucket", "bucket-from-us-west-2")

    const dist = new cloudfront.Distribution(this, "dist", {
        defaultBehavior: {
            origin: new origins.OriginGroup({
                primaryOrigin: new origins.S3Origin(sydBucket),
                fallbackOrigin: new origins.S3Origin(pdxBucket),

What did you expect to happen?

When I reference a bucket in the region that the stack is not in, and use it as a CloudFront origin I expect it to use the correct regional endpoint and not an invalid one. e.g. using ${bucketName}.s3-${region}

What actually happened?

This results in the origin group being created as expected, but the 2 S3 origins use the following path:

Obviously this does not work, and results in an error when accessing the distribution:

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.


  • CLI Version: 1.57
  • Framework Version: 1.57
  • Node.js Version: v12.13.1
  • OS: MacOS
  • Language (Version): all


This is 🐛 Bug Report

Issue Analytics

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

github_iconTop GitHub Comments

njlynchcommented, Aug 24, 2020

Re-opening (apologies – I thought requesters could re-open closed issues):

Thanks for pushing back a bit here. After taking a deeper look, I think that allowing you to specify the region of an imported bucket is a reasonable request, and fairly small at that. The proposal would be to allow either of the below to work:

const myImportedBucket = Bucket.fromArn(this, 'Bucket1', 'aws:s3:us-east-1:...'); // Sets region from ARN
const myOtherImportedBucket = Bucket.fromBucketAttributes(this, 'Bucket2', {
  bucketName: 'myBucket1235',
  region: 'us-east-1', // Set region explicitly

I’ll post a PR for this shortly and confer with the team on the above.

justin8commented, Aug 24, 2020

Awesome! Appreciate the fast feedback as always.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Amazon CloudFront with Multi-Region Amazon S3 Origins
To serve content from these other regions, we need to route requests to the different Amazon S3 buckets we're using. In this post,...
Read more >
CloudFront origin for specific region content - Stack Overflow
My recommendation is to use 1 S3 bucket only with folders specifying content depending on local (us, fr, gb, ...etc) and rely on...
Read more >
Getting started with a simple CloudFront distribution
Step 1: Upload your content to Amazon S3 and grant object permissions · Choose Create bucket. · For Bucket name, enter a bucket...
Read more >
Multi-region API Gateway with CloudFront - Awsstatic
AWS Reference Architecture. Multi-region API Gateway with CloudFront. Reduce latency for end-users, ... Regions, enable the Aurora Global.
Read more >
CloudFront with S3 Bucket Origin - AWS Well-Architected Labs
Create S3 bucket · Upload example index.html file · Configure Amazon CloudFront · Tear down. References & useful resources. Amazon S3 Developer Guide...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found