I'm getting InvalidBucketName when running under an aws account with restricted permissions
Closed this issue · 3 comments
Hi @miguelgrinberg, thanks for creating slam!
I wanted to try this out so I followed the instructions of the first tutorial (fizzbuzz). I'm getting an error which is possibly related to the fact that I'm using a child aws account which does not have permissions to certain actions. I did not try with the root account yet, but I thought it would be nice to have a --verbose
option to see what happened.
Here is the error log
2018-06-11 15:48:26,573 - slam - ERROR - [merry] Exception caught
Traceback (most recent call last):
File "~/fizz/venv/lib/python3.6/site-packages/slam/cli.py", line 256, in _ensure_bucket_exists
s3.head_bucket(Bucket=bucket)
File "~/fizz/venv/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "~/fizz/venv/lib/python3.6/site-packages/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (404) when calling the HeadBucket operation: Not Found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~/fizz/venv/lib/python3.6/site-packages/merry.py", line 26, in wrapper
ret = f(*args, **kwargs)
File "~/fizz/venv/lib/python3.6/site-packages/climax.py", line 194, in wrapper
ctx = func(**filtered_args)
File "~/fizz/venv/lib/python3.6/site-packages/slam/cli.py", line 368, in deploy
_ensure_bucket_exists(s3, bucket, region)
File "~/fizz/venv/lib/python3.6/site-packages/slam/cli.py", line 262, in _ensure_bucket_exists
s3.create_bucket(Bucket=bucket)
File "~/fizz/venv/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "~/fizz/venv/lib/python3.6/site-packages/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidBucketName) when calling the CreateBucket operation: The specified bucket is not valid.
The error suggests the S3 bucket that you requested does not exist.
This issue will be automatically closed due to being inactive for more than six months. Please reopen if you need more assistance.
I think this happens because one cannot use capital letters in S3 bucket names. According to the AWS-docs: https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-).
In the code (init(), line 119), it says:
random.choice(string.ascii_uppercase + string.digits)
changing this to:
random.choice(string.ascii_lowercase + string.digits)
makes the bucket creation operation succeed.