Skip to content

'us-east-1` is not a valid region when creating s3 bucket #16978

@xuzha

Description

@xuzha

Elasticsearch version: master

JVM version: 1.8

OS version: OSX

Describe the feature:

When we using us-east-1, s3 plugin will first get the endpoint by using the region, and then use the endpoint to create the client, this is fine.

But when creating the bucket, s3 plugin will will the bucket name to build a CreateBucketRequest (link), us-east-1 is not valid for aws s3 sdk.

Reproduce:

PUT _snapshot/test-1
{
  "type": "s3",
  "settings": {
    "bucket": "test-us-east-1",
    "region": "us-east-1"
  }
}
{
   "error": {
      "root_cause": [
         {
            "type": "repository_exception",
            "reason": "[test-6] failed to create repository"
         }
      ],
      "type": "repository_exception",
      "reason": "[test-6] failed to create repository",
      "caused_by": {
         "type": "creation_exception",
         "reason": "Guice creation errors:\n\n1) Error injecting constructor, com.amazonaws.services.s3.model.AmazonS3Exception: The specified location-constraint is not valid (Service: Amazon S3; Status Code: 400; Error Code: InvalidLocationConstraint; Request ID: 85CFF34E01878232), S3 Extended Request ID: Ob5XZJsy8IH7HaZy/moMNAgvaH3ZIrHN9fxyimecIp+xtMZI8nE/sc2YVIoTuf2SuEXyoiQP1wE=\n  at org.elasticsearch.repositories.s3.S3Repository.<init>(Unknown Source)\n  while locating org.elasticsearch.repositories.s3.S3Repository\n  while locating org.elasticsearch.repositories.Repository\n\n1 error",
         "caused_by": {
            "type": "amazon_s3_exception",
            "reason": "The specified location-constraint is not valid (Service: Amazon S3; Status Code: 400; Error Code: InvalidLocationConstraint; Request ID: 85CFF34E01878232)"
         }
      }
   },
   "status": 500
}

Succeed after removed the region

PUT _snapshot/test-1
{
  "type": "s3",
  "settings": {
    "bucket": "test-us-east-1"
  }
}

Same thing happened if we used us-west | ap-southeast | eu-central...
I think if we could get the endpoint, we should using the valid region name and let user be able to create buckets.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions