I'm getting cloudfront endpoint redirecting to S3 with 307 Temporary Redirect
. Is there a reason why this is happening?
I've tried creating website endpoint and changed the origin but no luck with same result.
I'm getting cloudfront endpoint redirecting to S3 with 307 Temporary Redirect
. Is there a reason why this is happening?
I've tried creating website endpoint and changed the origin but no luck with same result.
The Temporary Request Redirection
It's actually caused by the way S3 buckets behave when they are newly-created (thanks to @Michael-sqlbot) for clarifying this.
From the docs (Temporary Request Redirection)
Due to the distributed nature of Amazon S3, requests can be temporarily routed to the wrong facility. This is most likely to occur immediately after buckets are created or deleted. For example, if you create a new bucket and immediately make a request to the bucket, you might receive a temporary redirect, depending on the location constraint of the bucket.
Change your Origin Domain Name to bucketname.s3-region.amazonaws.com per the docs:
If you're using an Amazon CloudFront distribution with an Amazon S3 origin, CloudFront forwards requests to the default S3 endpoint (s3.amazonaws.com), which is in the us-east-1 Region. If you must access Amazon S3 within the first 24 hours of creating the bucket, you can change the Origin Domain Name of the distribution to include the regional endpoint of the bucket. For example, if the bucket is in us-west-2, you can change the Origin Domain Name from bucketname.s3.amazonaws.com to bucketname.s3-us-west-2.amazonaws.com.