I’m using aws s3 SDK in my code. In my tests I’m trying to create/drop buckets for the test.
My sdk version is 1.11.800 :
<aws-s3-sdk.version>1.11.800</aws-s3-sdk.version> <aws-java-sdk-core.version>1.11.800</aws-java-sdk-core.version>
The creation’s code is exactly the same as in aws examples :
public void createBucket(String bucketName){ try { 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(); } }
The exception :
22:32:33.949 [main] DEBUG com.amazonaws.request - Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: You have attempted to create more buckets than allowed (Service: Amazon S3; Status Code: 400; Error Code: TooManyBuckets; Request ID: 4FE57EE4ACC6C7E4; S3 Extended Request ID: qIzyYNg6Il9J+ehR+JM3W5+RZWg43GJIU9v4EA5ajHG05bUydw8lN3qLZY5u/QjdXhV8tJlINMk=; Proxy: null), S3 Extended Request ID: qIzyYNg6Il9J+ehR+JM3W5+RZWg43GJIU9v4EA5ajHG05bUydw8lN3qLZY5u/QjdXhV8tJlINMk= com.amazonaws.services.s3.model.AmazonS3Exception: You have attempted to create more buckets than allowed (Service: Amazon S3; Status Code: 400; Error Code: TooManyBuckets; Request ID: 4FE57EE4ACC6C7E4; S3 Extended Request ID: qIzyYNg6Il9J+ehR+JM3W5+RZWg43GJIU9v4EA5ajHG05bUydw8lN3qLZY5u/QjdXhV8tJlINMk=; Proxy: null), S3 Extended Request ID: qIzyYNg6Il9J+ehR+JM3W5+RZWg43GJIU9v4EA5ajHG05bUydw8lN3qLZY5u/QjdXhV8tJlINMk= at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1811) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1395) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1371) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704) at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5062) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5008) at com.amazonaws.services.s3.AmazonS3Client.createBucket(AmazonS3Client.java:1097)
I got more than 100 buckets in my account but when I try to create a bucket in the aws console I create it successfully without any problems.
When I create the bucket manually and run my other tests (that don’t create this bucket) I can successfully put and delete content from the bucket so it isn’t a credentials issue.
Advertisement
Answer
By default, an AWS account is soft limited to 100 S3 buckets.
You need to submit a service limit increase request by creating a new case through the support portal.. Once they override the default soft limit on your account you may create up to 1000 S3 buckets.
Read more about bucket restrictions here