AWS AmazonS3 documentation change
Summary
Replaced Java SDK bucket creation examples with API reference links and added guidance about using GUIDs for unique bucket names
Security assessment
While the GUID recommendation helps prevent bucket naming conflicts (a reliability concern), this does not directly address security vulnerabilities or add security features. The change primarily consolidates code examples into external references and provides naming best practices without security-specific context.
Diff
diff --git a/AmazonS3/latest/userguide/create-bucket-overview.md b/AmazonS3/latest/userguide/create-bucket-overview.md index 5d6b3e1fa..121be08f8 100644 --- a//AmazonS3/latest/userguide/create-bucket-overview.md +++ b//AmazonS3/latest/userguide/create-bucket-overview.md @@ -210,74 +210 @@ Java -###### Example Create a bucket that uses a globally unique identifier (GUID) in the bucket name - -The following example shows you how to create a with a GUID at the end of the bucket name in US East (N. Virginia) Region (`us-east-1`) by using the AWS SDK for Java. To use this example, replace the ``user input placeholders`` with your own information. For information about other AWS SDKs, see [Tools to Build on AWS](https://aws.amazon.com/developer/tools/). - - - 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); - } - } - -###### Example Create a general purpose bucket - -This example shows you how to create an Amazon S3 bucket by using the AWS SDK for Java. For instructions on creating and testing a working sample, see the [AWS SDK for Java 2.x Developer Guide](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html). - - - import com.amazonaws.AmazonServiceException; - import com.amazonaws.SdkClientException; - import com.amazonaws.auth.profile.ProfileCredentialsProvider; - import com.amazonaws.regions.Regions; - import com.amazonaws.services.s3.AmazonS3; - import com.amazonaws.services.s3.AmazonS3ClientBuilder; - import com.amazonaws.services.s3.model.CreateBucketRequest; - import com.amazonaws.services.s3.model.GetBucketLocationRequest; - - import java.io.IOException; - - public class CreateBucket2 { - - public static void main(String[] args) throws IOException { - Regions clientRegion = Regions.DEFAULT_REGION; - String bucketName = "*** Bucket name ***"; - - try { - AmazonS3 s3Client = AmazonS3ClientBuilder.standard() - .withCredentials(new ProfileCredentialsProvider()) - .withRegion(clientRegion) - .build(); - - if (!s3Client.doesBucketExistV2(bucketName)) { - // Because the CreateBucketRequest object doesn't specify a region, the - // bucket is created in the region specified in the client. - s3Client.createBucket(new CreateBucketRequest(bucketName)); - - // Verify that the bucket was created by retrieving it and checking its - // location. - String bucketLocation = s3Client.getBucketLocation(new GetBucketLocationRequest(bucketName)); - System.out.println("Bucket location: " + bucketLocation); - } - } catch (AmazonServiceException e) { - // The call was transmitted successfully, but Amazon S3 couldn't process - // it and returned an error response. - e.printStackTrace(); - } catch (SdkClientException e) { - // Amazon S3 couldn't be contacted for a response, or the client - // couldn't parse the response from Amazon S3. - e.printStackTrace(); - } - } - } - +For examples of how to create a bucket with the AWS SDK for Java, see [Create a bucket](https://docs.aws.amazon.com/AmazonS3/latest/API/s3_example_s3_CreateBucket_section.html) in the _Amazon S3 API Reference_. @@ -284,0 +212 @@ This example shows you how to create an Amazon S3 bucket by using the AWS SDK fo +When using the AWS SDK for Java v2, you can create a general purpose bucket with a globally unique identifier (GUID) appended to the bucket name to ensure uniqueness. Use `UUID.randomUUID().toString().replace("-", "")` to generate a GUID and concatenate it with your base bucket name. This approach helps avoid bucket naming conflicts across all AWS accounts.