Created
September 10, 2021 03:32
-
-
Save PraneethKarnena/93d79f3cc924c1fc6bb831109bdf308e to your computer and use it in GitHub Desktop.
Celery SQS settings for Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kombu.utils.url import safequote | |
SQS = config('SQS', cast=bool, default=False) | |
if SQS: | |
SQS_ACCESS_KEY = config('SQS_ACCESS_KEY', cast=str) | |
SQS_SECRET_KEY = config('SQS_SECRET_KEY', cast=str) | |
SQS_URL = config('SQS_URL', cast=str) | |
CELERY_BROKER_URL = f'sqs://{safequote(SQS_ACCESS_KEY)}:{safequote(SQS_SECRET_KEY)}@' | |
CELERY_TASK_DEFAULT_QUEUE = 'main-queue.fifo' | |
CELERY_BROKER_TRANSPORT_OPTIONS = { | |
'region': 'us-west-2', | |
'predefined_queues': { | |
'main-queue.fifo': { | |
'url': SQS_URL, | |
'access_key_id': SQS_ACCESS_KEY, | |
'secret_access_key': SQS_SECRET_KEY, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment