General purpose bucket naming rules
When you create a general purpose bucket, you choose its name and the Amazon Web Services Region to create it in. After you create a general purpose bucket, you can't change its name or Region. The following sections provide information about general purpose bucket naming, including naming rules, best practices, and an example for creating a general purpose bucket with a name that includes a globally unique identifier (GUID).
For directory bucket naming rules, see Directory bucket naming rules.
For information on object key names, see Creating object key names
Topics
General purpose buckets naming rules
The following naming rules apply for general purpose buckets.
-
Bucket names must be between 3 (min) and 63 (max) characters long.
-
Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-).
-
Bucket names must begin and end with a letter or number.
-
Bucket names must not contain two adjacent periods.
-
Bucket names must not be formatted as an IP address (for example, 192.168.5.4).
-
Bucket names must not start with the prefix
xn--
. -
Bucket names must not start with the prefix
sthree-
. -
Bucket names must not start with the prefix
sthree-configurator
. -
Bucket names must not start with the prefix
amzn-s3-demo-
. -
Bucket names must not end with the suffix
-s3alias
. This suffix is reserved for access point alias names. For more information, see Using a bucket-style alias for your S3 bucket access point. -
Bucket names must not end with the suffix
--ol-s3
. This suffix is reserved for Object Lambda Access Point alias names. For more information, see How to use a bucket-style alias for your S3 bucket Object Lambda Access Point. -
Bucket names must not end with the suffix
.mrap
. This suffix is reserved for Multi-Region Access Point names. For more information, see Rules for naming Amazon S3 Multi-Region Access Points. -
Bucket names must not end with the suffix
--x-s3
. This suffix is reserved for directory buckets. For more information, see Directory bucket naming rules. -
Bucket names must be unique across all Amazon Web Services accounts in all the Amazon Web Services Regions within a partition. A partition is a grouping of Regions. Amazon currently has three partitions:
aws
(Standard Regions),aws-cn
(China Regions), andaws-us-gov
(Amazon GovCloud (US)). -
A bucket name cannot be used by another Amazon Web Services account in the same partition until the bucket is deleted.
-
Buckets used with Amazon S3 Transfer Acceleration can't have dots (.) in their names. For more information about Transfer Acceleration, see Configuring fast, secure file transfers using Amazon S3 Transfer Acceleration.
Important
-
Bucket names must be unique across all Amazon Web Services accounts in all the Amazon Web Services Regions within a partition. A partition is a grouping of Regions. Amazon currently has three partitions:
aws
(Standard Regions),aws-cn
(China Regions), andaws-us-gov
(Amazon GovCloud (US)). -
A bucket name cannot be used by another Amazon Web Services account in the same partition until the bucket is deleted. After you delete a bucket, be aware that another Amazon Web Services account in the same partition can use the same bucket name.
Note
Before March 1, 2018, buckets created in the US East (N. Virginia) Region could have names that were up to 255 characters long and included uppercase letters and underscores. Beginning March 1, 2018, new buckets in US East (N. Virginia) must conform to the same rules applied in all other Regions.
Example general purpose bucket names
The following example bucket names are valid and follow the recommended naming guidelines for general purpose buckets:
-
docexamplebucket-1a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa
-
amzn-s3-demo-bucket1-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
-
amzn-s3-demo-bucket-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222
-
amzn-s3-demo-bucket2
The following example bucket names are valid but not recommended for uses other than static website hosting:
-
example.com
-
www.example.com
-
my.example.s3.bucket
The following example bucket names are not valid:
-
amzn_s3_demo_bucket
(contains underscores) -
AmznS3DemoBucket
(contains uppercase letters) -
amzn-s3-demo-bucket-
(ends with a hyphen)
Best practices
When naming your buckets, consider the following bucket naming best practices.
Choose a bucket naming scheme that is unlikely to cause naming conflicts
If your application automatically creates buckets, choose a bucket naming scheme that is unlikely to cause naming conflicts. Ensure that your application logic will choose a different bucket name if a bucket name is already taken.
Append globally unique identifiers (GUID) to bucket names
We recommend that you create bucket names that are not predictable. Do not write
code assuming your chosen bucket name is available unless you have already created
the bucket. One method for creating bucket names that are not predictable is to
append a Globally Unique Identifier (GUID) to your bucket name, for example,
amzn-s3-demo-bucket-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
.
Avoid using dots (.) in bucket names
For best compatibility, we recommend that you avoid using dots (.) in bucket names, except for buckets that are used only for static website hosting. If you include dots in a bucket's name, you can't use virtual-host-style addressing over HTTPS, unless you perform your own certificate validation. This is because the security certificates used for virtual hosting of buckets don't work for buckets with dots in their names.
This limitation doesn't affect buckets used for static website hosting, because static website hosting is only available over HTTP. For more information about virtual-host-style addressing, see Virtual hosting of buckets. For more information about static website hosting, see Hosting a static website using Amazon S3.
Choose a relevant name
When you name a bucket, we recommend that you
choose a name that is relevant to you or your business. Avoid using names associated with others. For
example, you should avoid using AWS
or Amazon
in your bucket name.
Reusing bucket names
If a bucket is empty, you can delete it. After a bucket is deleted, the name becomes available for reuse. However, after you delete the bucket, you might not be able to reuse the name for various reasons.
For example, when you delete the bucket and the name becomes available for reuse, another Amazon Web Services account might create a bucket with that name. In addition, some time might pass before you can reuse the name of a deleted bucket. If you want to use the same bucket name, we recommend that you don't delete the bucket.
Creating a bucket that uses a GUID in the bucket name
The following examples show you how to create a general purpose bucket that uses a GUID at the end of the bucket name.
The following Amazon CLI example creates a bucket in the US West (N. California) Region (us-west-1) Region with an example bucket name that uses a globally unique identifier (GUID).
aws s3api create-bucket \ --bucket
amzn-s3-demo-bucket1
$(uuidgen | tr -d - | tr '[:upper:]' '[:lower:]' ) \ --regionus-west-1
\ --create-bucket-configuration LocationConstraint=us-west-1
The following example shows you how to create a bucket with a GUID at the end
of the bucket name in US East (N. Virginia) Region (us-east-1;) by using the
Amazon SDK for Java. For information about other Amazon SDKs, see Tools to Build on Amazon
import com.amazonaws.regions.Regions; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.Bucket; import com.amazonaws.services.s3.model.CreateBucketRequest; import java.util.List; import java.util.UUID; public class CreateBucketWithUUID { public static void main(String[] args) { final AmazonS3 s3 = AmazonS3ClientBuilder.standard().withRegion(Regions.
US_EAST_1
).build(); String bucketName = "amzn-s3-demo-bucket
" + UUID.randomUUID().toString().replace("-", ""); CreateBucketRequest createRequest = new CreateBucketRequest(bucketName); System.out.println(bucketName); s3.createBucket(createRequest); } }