Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bucket naming needs validation #9

Open
nealtodd opened this issue Jun 27, 2018 · 2 comments
Open

Bucket naming needs validation #9

nealtodd opened this issue Jun 27, 2018 · 2 comments

Comments

@nealtodd
Copy link
Member

nealtodd commented Jun 27, 2018

Bucket names cannot, for example, include underscores (see https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html for full naming requirements).

The Bucket name? prompt allows an invalid name but the creation will fail after the Do you want to create a bucket with the above details? prompt with:

botocore.exceptions.ClientError: An error occurred (InvalidBucketName) when calling the CreateBucket operation: The specified bucket is not valid.

@tm-kn
Copy link
Member

tm-kn commented Jun 27, 2018

Thanks!

We currently check for ParamValidationError, but we probably also do check for ClientError. ParamValidationError may have worked before because we might have been using resource rather than the client, so need to evaluate whether it still relevant as well.

except ClientError as e:
# Bucket does not exist, proceed with creation.
if e.response['Error']['Code'] == '404':
return
# No access to the bucket means that it already exists but we
# cannot run head request on it.
elif e.response['Error']['Code'] == '403':
raise BucketNameAlreadyInUse
else:
raise e

@tm-kn
Copy link
Member

tm-kn commented Jun 27, 2018

Ah, it fails when creating the bucket... boto3 has a wrong regex for bucket names itself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants