Skip to content

S3.createBucket with LocationContraint: '' fails #526

@e-gineer

Description

@e-gineer

Creating an S3 bucket while setting the LocationConstraint to an empty string fails, but should work as a valid setting for US Standard according to the documentation at:

The workaround is simple enough (just remove LocationConstraint when working in US Standard), but I wanted to bring this to your attention / confirm it's not just me .

Code to reproduce:

aws = require 'aws-sdk'

#
# Works, as expected, creating bucket in US Standard
#

params =
  Bucket: 'bucket-test-should-work-in-us-standard'

conn = new aws.S3
  signatureVersion: 'v4'
  s3ForcePathStyle: true

conn.createBucket params, (err, result) ->
  console.dir err
  console.dir result


#
# Fails, as expected, invalid location constraint since us-east-1 is not valid
#

params =
  Bucket: 'bucket-test-should-fail'
  CreateBucketConfiguration:
    LocationConstraint: 'us-east-1'

conn = new aws.S3
  signatureVersion: 'v4'
  s3ForcePathStyle: true

conn.createBucket params, (err, result) ->
  console.dir err
  console.dir result


#
# FAILS, UNEXPECTED.
# Accoding to http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html
# and http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#createBucket-property
# an empty string should be a valid location constraint for US Standard region.
#

params =
  Bucket: 'bucket-test-should-work-but-doesnt'
  CreateBucketConfiguration:
    LocationConstraint: ''

conn = new aws.S3
  signatureVersion: 'v4'
  s3ForcePathStyle: true

conn.createBucket params, (err, result) ->
  console.dir err
  console.dir result


#
# FAILS, UNEXPECTED.
# Confirming that changing the connection path style still doesn't help.
#

params =
  Bucket: 'bucket-test-should-work-but-doesnt-region'
  CreateBucketConfiguration:
    LocationConstraint: ''

conn = new aws.S3
  region: 'us-east-1'

conn.createBucket params, (err, result) ->
  console.dir err
  console.dir result

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.service-apiThis issue is due to a problem in a service API, not the SDK implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions