Search code examples
amazon-web-servicesamazon-s3aws-lambdaaws-cliserverless-application-model

AWS CLI - Create s3 bucket from Linux error


I'm using AWS CLI to create the S3 bucket. I have installed the AWS CLI and running following command to create the bucket

aws s3 mb s3://Test-sam-bucket --region us-west-1

Error: make_bucket failed: s3://Test-sam-bucket An error occurred (InvalidBucketName) when calling the CreateBucket operation: The specified bucket is not valid.

also, I have tried with:

aws s3 mb s3://sambucket --region us-west-1

Error: make_bucket failed: s3://sambucket An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.

What am I doing wrong please help


Solution

  • Regarding the first point where you are taking Test-sam-bucket name:

    • do not use any special character between the bucket name, simply use testsambucket that would surely work with you.

    Regarding your second point where you are getting the BucketAlreadyExists message:

    • It is because the S3 bucket name is global namespace in S3 shared by another S3 user as well. Therefore, it has been unique at the global level.

    • You can try with your own custom unique names like some combination of your teamName+BucketName or something else.

    • The issue with Test-sam-bucket is that the first character can not be an upper case in bucket name, it can either be a lower case character or number. We can have hyphens in bucket names. More details about the restrictions can be found here: docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html