Zappa异步任务导致Amazon Cloudfront生成403错误请求

时间:2019-09-19 14:22:22

标签: aws-lambda amazon-cloudfront zappa

我试图在我的项目中第一次使用Zappa异步任务。我不断收到来自Amazon Cloudfront的403错误请求。 这是代码-

@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())))

有人在想什么吗?

1 个答案:

答案 0 :(得分:0)

装饰器应该是这样的,

@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):