Search code examples
aws-lambdaamazon-cloudfrontzappa

Zappa async task results in 403 Bad Request Generated by Amazon Cloudfront


I am trying to use the Zappa Async task for the first time in my project. I keep getting 403 Bad request from Amazon cloudfront. Here is the code -

@task
def send_email(email_id):
    start = datetime.now()
    sleep(120)
    body = """zappa task started at {}
              waited for 100.
              mail sent at: {}""".format(str(start), str(datetime.now()))
    send_mail("Zappa Task Email", body, settings.EMAIL_HOST_USER, [email_id])

####

class zappa_task(APIView):
    def get(self, request, version):
        email = request.GET.get('email')
        t = datetime.now()
        send_email(email)

        return httpResponse('Zappa task triggered at: {}, code returned at: {}'.format(str(t), str(datetime.now())))

Any thoughts anyone?


Solution

  • The decorator should be like this ,

    @task(remote_aws_lambda_function_name=("provide the deployed lambda function name here on which it has to run"), remote_aws_region="the region name here")
    def send_email(email_id):