I am working on a software function in which I have to periodically delete files using Django + cron + AWS . The problem is that I cannot get it to work. What is the best way to make it work? Is any AWS configuration missing? I set up one web server and one worker , deployed the same version of the application on them. A task is a view displayed in url (access to the url that the function is executing). In the working environment, a confirmation message appears:
Successfully uploaded 1 scheduled task from cron.yaml.
But also error 403 for working access_log :
"POST / networks_app / delete_expired_files HTTP / 1.1" 403 2629 "-" "aws-sqsd / 2.0"
cron.yaml
version: 1 cron: - name: "delete_expired_files" url: "/networks_app/delete_expired_files" schedule: "10 * * * *"
Url in urls.py :
urlpatterns = [ url(r'^delete_expired_files', views.delete_expired_files, name='delete_expired_files'), ]
to delete files from views.py :
def delete_expired_files(request): users = DemoUser.objects.all() for user in users: documents = Document.objects.filter(owner=user.id) if documents: for doc in documents: now = timezone.now() if now >= doc.date_published + timedelta(days=doc.owner.group.valid_time): doc.delete()
My IAM roles:
AmazonSQSFullAccess
AmazonS3FullAccess
AWSElasticBeanstalkFullAccess
AmazonDynamoDBFullAccess
If I access the URL through a browser, the task is executed (expired files are deleted). However, the work environment had to access the URL and complete the task automatically, and not just when accessing the URL through a browser. How can I make it work?
source share