question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not recognise the bucket name

See original GitHub issue

I am using django-s3-storage==0.11.2 and boto3==1.4.4. These are in the settings.py:

	STATIC_URL = '/static/'
	STATICFILES_DIRS = [
	    os.path.join(BASE_DIR, "static"),
	]
	STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn')
	MEDIA_URL = '/media/'
	MEDIA_ROOT = os.path.join(BASE_DIR, 'media_cdn')

	AWS_S3_BUCKET_NAME = "my-bucket-name"
	AWS_ACCESS_KEY_ID = 'test_id_x'
	AWS_SECRET_ACCESS_KEY = 'test_id_x+test_id_x'
	DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage"
	STATICFILES_STORAGE = "django_s3_storage.storage.StaticS3Storage"
	AWS_S3_ADDRESSING_STYLE = "auto"
	AWS_S3_BUCKET_AUTH_STATIC = False
	AWS_S3_MAX_AGE_SECONDS_STATIC =  60 * 60 * 24 * 365  # 1 year.
	AWS_S3_BUCKET_AUTH = False
	AWS_S3_MAX_AGE_SECONDS = 60 * 60 * 24 * 365  # 1 year.

I have also ran these command:

manage.py s3_sync_meta django.core.files.storage.default_storage

But when I run collectstatic or this command

manage.py s3_sync_meta django.contrib.staticfiles.storage.staticfiles_storage

I get this error:

botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid bucket name “”: Bucket name must match the regex “^[a-zA-Z0-9.-_]{1,255}$”

I have already created the bucket, and the bucket name is correct, because this works and does not gives any error:

`s3.meta.client.head_bucket(Bucket='my-bucket-name')`

I don’t know what am I missing here? Could you help me out please.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jameslscommented, Jun 14, 2017

I’m not that familiar with django-storages configuration, but the code that generates the error message is:

    if VALID_BUCKET.search(bucket) is None:
        error_msg = (
            'Invalid bucket name "%s": Bucket name must match '
            'the regex "%s"' % (bucket, VALID_BUCKET.pattern))
        raise ParamValidationError(report=error_msg)

In this case the error message say Invalid bucket name "", which means that the bucket name is empty. This is likely a configuration error with django storages.

I would suggest either reaching out to the django storages people or asking on stack overflow.

Glancing over their docs (http://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html), it looks like the bucket name is specified via AWS_STORAGE_BUCKET_NAME which I don’t see in your settings.py. Hope that helps.

0reactions
vonmutindacommented, Aug 29, 2019

If deployed on heroku in config Vars make sure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and NOT in quotes.

Worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django s3 storages does not recognise the bucket name
1 Answer 1 ; My bucket name is bass-line-shop , which should resemble the regex pattern. And also, changing AWS_STORAGE_BUCKET_NAME doesn't help.
Read more >
Bucket naming rules - Amazon Simple Storage Service
Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-). Bucket names must begin and end with a letter...
Read more >
flow don't recognize the Bucket id - Power Platform Community
Solved: Hi, i have a flow to create list of tasks based on an excel table, where each row is translated into a...
Read more >
django s3 storages does not recognise the bucket name-django
Bucket name should not have '/' in them . It would be good if you can update the AWS_S3_BUCKET_NAME from "my-bucket-name" to the...
Read more >
About Cloud Storage buckets
Bucket names can only contain lowercase letters, numeric characters, dashes ( - ), underscores ( _ ), and dots ( . ). Spaces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found