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.

S3 bucket cannot be created if region is set

See original GitHub issue

I’m trying to get Lambda@Edge working with Cloudfront in CDK. To make things easy, I was hoping that I could override my default region (us-west-2) for my whole stack so that the Lambda would be deployed in us-east-1, as required by Lambda@Edge functions.

However, when I set the region as a prop, the S3 bucket creation fails with status code 400.

If I remove the region property, the bucket is created without a problem.

Reproduction Steps

export abstract class ExampleStack extends Stack {
  constructor(scope: Construct, id: string, props) {
    super(scope, id, {
      env: {
        region: "us-east-1",
      },
    });
	
	new Bucket(this, "MyBucket", {
	  bucketName: 'somesuch-bucket-foobar',
    }
  }
}

Error Log

 1/3 | 3:21:58 PM | CREATE_FAILED        | AWS::S3::Bucket    | Bucket (Bucket83908E77) Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: 0FB9C10A83924370; S3 Extended Request ID: Vr8/8sYPDksJgYQ1IaFbpAA32xHSCohJnyXGoVjAOo1Z6gsQ5eHGNmQ06sEfsi6WaC3Y/1IcNfo=)

Environment

  • CLI Version : 1.27.0 (build a98c0b3)
  • Framework Version: 1.27.0
  • OS : macOS
  • Language : en-us

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
blimmercommented, Mar 11, 2020

Hey @iliapolo - thanks for checking back in. Yep, I think we’re good to close this.

For future travelers, if you run into this, a few things to try:

  1. Are you trying to recreate an s3 bucket in a new region, after you deleted a bucket with the same name from another region? If so, that can cause the 400 status code. I couldn’t find official documentation on this, but it seems like the name is “released” for the bucket to be recreated in a new region 24 hours after it’s deleted in the old region.

  2. From the docs, it looks like you should pass the account number and and the region if you try to specify a region in the env param.

5reactions
ansmancommented, Feb 15, 2021

Same here, I had the exact same experience as @J-Swift. I spent 2 hours try to debug this. Perhaps if the error message could be included instead of just the code this would be easier to debug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot create Amazon S3 Bucket in specified region
when calling the CreateBucket operation: A conflicting conditional operation is currently in progress against this resource.
Read more >
Buckets overview - Amazon Simple Storage Service
Amazon S3 supports global buckets, which means that each bucket name must be unique across all AWS accounts in all the AWS Regions...
Read more >
Amazon S3 Bucket region and name restrictions and ...
When creating the S3 bucket name you will be required to select "US East (N. Virginia)" for the region name. The reason that...
Read more >
How to transfer my Amazon S3 Bucket to another region
But what you can do is, create another bucket in the new region and use Cross Region Replication(CRR) to transfer files from the...
Read more >
What is Amazon S3 bucket? | Definition from TechTarget
An Amazon S3 bucket is a public cloud storage resource available in Amazon Web Services' (AWS) Simple Storage Service (S3), an object storage...
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