/* * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.s3.model; import com.amazonaws.regions.RegionUtils; import com.amazonaws.services.s3.internal.Constants; import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; /** * Specifies constants that define Amazon S3 Regions. *
* Amazon S3 Regions allow the user to choose the geographical region where * Amazon S3 will store the buckets the user creates. Choose a Amazon S3 Region * to optimize latency, minimize costs, or address regulatory requirements. *
** Objects stored in a Amazon S3 Region never leave that region unless explicitly * transferred to another region. *
** In Amazon S3, all the regions provides * read-after-write consistency for PUTS of new objects in Amazon * S3 buckets and eventual consistency for overwrite PUTS and DELETES. *
*/ public enum Region { /** * The US Standard Amazon S3 Region. This region uses Amazon S3 servers * located in the United States. *
* This is the default Amazon S3 Region. All requests sent to
* s3.amazonaws.com
go to this region unless a location
* constraint is specified when creating a bucket. The US Standard Region
* automatically places data in either Amazon's east or west coast data
* centers depending on which one provides the lowest latency. The US
* Standard Region provides eventual consistency for all requests.
*
* When using buckets in this region, set the client endpoint to
* s3-us-east-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-us-west-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* In Amazon S3, the US-West (Northern California) Region provides * read-after-write consistency for PUTS of new objects in Amazon S3 buckets * and eventual consistency for overwrite PUTS and DELETES. *
*/ US_West("us-west-1"), /** * The US-West-2 (Oregon) Region. This region uses Amazon S3 servers located * in Oregon. *
* When using buckets in this region, set the client endpoint to
* s3-us-west-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* In Amazon S3, the EU (Ireland) Region provides read-after-write * consistency for PUTS of new objects in Amazon S3 buckets and eventual * consistency for overwrite PUTS and DELETES. *
*/ EU_Ireland("eu-west-1", "EU"), /** * The EU (London) Amazon S3 Region. This region uses Amazon S3 servers * located in London. *
* When using buckets in this region, set the client endpoint to
* s3.eu-west-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3.eu-west-3.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* Note that to access S3 buckets in Frankfurt you must explicitly set the * region on the AWS S3 Client you are working with. In Amazon S3, the EU * (Franfkurt) Region provides read-after-write consistency for PUTS of new * objects in Amazon S3 buckets and eventual consistency for overwrite PUTS * and DELETES. *
*/ EU_Frankfurt("eu-central-1"), /** * The EU (Zurich) Region. This region uses Amazon S3 servers * located in Zurich. *
* When using buckets in this region, set the client endpoint to
* s3-eu-central-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* Note that to access S3 buckets in Stockholm you must explicitly set the * region on the AWS S3 Client you are working with. In Amazon S3, the EU * (Stockholm) Region provides read-after-write consistency for PUTS of new * objects in Amazon S3 buckets and eventual consistency for overwrite PUTS * and DELETES. *
*/ EU_Stockholm("eu-north-1"), /** * The Asia Pacific (Hong Kong) Region. This region uses Amazon S3 servers * located in Hong Kong. *
* When using buckets in this region, set the client endpoint to
* s3-ap-east-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-south-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-southeast-1.amazonaws.com
on all requests to these
* buckets to reduce any latency experienced after the first hour of
* creating a bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-southeast-2.amazonaws.com
on all requests to these
* buckets to reduce any latency experienced after the first hour of
* creating a bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-northeast-1.amazonaws.com
on all requests to these
* buckets to reduce any latency experienced after the first hour of
* creating a bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3.ap-northeast-2.amazonaws.com
on all requests to these
* buckets to reduce any latency experienced after the first hour of
* creating a bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-sa-east-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3.ca-central-1.amazonaws.com
on all requests to these
* buckets to reduce any latency experienced after the first hour of
* creating a bucket in this region.
*
* When using buckets in this region, you must set the client endpoint to
* s3.cn-north-1.amazonaws.com.cn
.
*/
CN_Beijing("cn-north-1"),
/**
* The China (Ningxia) Region. This region uses Amazon S3 servers located in
* Ningxia.
*
* When using buckets in this region, you must set the client endpoint to
* s3.cn-northwest-1.amazonaws.com.cn
.
*/
CN_Ningxia("cn-northwest-1"),
/**
* The Middle East (Bahrain) Region. This region uses Amazon S3 servers located in
* Bahrain.
*
* When using buckets in this region, you must set the client endpoint to
* s3.me-south-1.amazonaws.com
.
*/
ME_Bahrain("me-south-1"),
/**
* The Europe (Milan) Region. This region uses Amazon S3 servers
* located in Milan.
*
* When using buckets in this region, set the client endpoint to
* s3-eu-south-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-eu-south-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-af-south-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-southeast-3.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-me-central-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-south-2.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-ap-southeast-4.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* When using buckets in this region, set the client endpoint to
* s3-il-central-1.amazonaws.com
on all requests to these buckets
* to reduce any latency experienced after the first hour of creating a
* bucket in this region.
*
* s3-eu-west-1.amazonaws.com * s3.cn-north-1.amazonaws.com.cn **/ public static final Pattern S3_REGIONAL_ENDPOINT_PATTERN = Pattern .compile("s3[-.]([^.]+)\\.amazonaws\\.com(\\.[^.]*)?"); /** The list of ID's representing each region. */ private final List
IllegalArgumentException
is
* thrown.
*
* @param s3RegionId The Amazon S3 region ID string.
* @return The Amazon S3 Region enumeration value representing the specified
* Amazon S3 Region ID.
* @throws IllegalArgumentException If the specified value does not map to
* one of the known Amazon S3 regions.
*/
public static Region fromValue(final String s3RegionId) throws IllegalArgumentException
{
if (s3RegionId == null || s3RegionId.equals("US") || s3RegionId.equals("us-east-1")) {
return Region.US_Standard;
}
for (final Region region : Region.values()) {
final List