无法将_event_notification添加到s3以触发Lambda

问题描述

我无法将_event_notification添加到s3存储桶以触发Lambda函数。我的环境基于python36和AWS CDK 1.57.0。而是使用未知的内联服务代码形成一个新函数。

from aws_cdk import (
    aws_s3 as s3,core,aws_iam as iam,aws_lambda as lambda_,aws_s3_notifications as s3n)


LAB1IndexFile = "/Users/algh/als_code/AWS/lambda_cron_test/lambda_textract/index.py"
class TextractComprehendWorkshopStack(core.Stack):
    def __init__(self,scope: core.Construct,id: str,**kwargs) -> None:
        super().__init__(scope,id,**kwargs)
        with open(LAB1IndexFile,encoding="utf8") as fp:
            lab1_handler_code = fp.read()
        bucket_ = s3.Bucket(self,id="xx",bucket_name="wshop-textract-bucket")
        inline_pol_state_s3 = iam.PolicyStatement(actions=["s3:get*"],effect=iam.Effect.ALLOW,resources=[bucket_.bucket_arn])
        inline_pol_doc_s3 = iam.PolicyDocument(statements=[inline_pol_state_s3])
        inline_pol_state_textract =  iam.PolicyStatement(actions=["textract:*"],resources=[bucket_.bucket_arn])
        inline_pol_doc_textract = iam.PolicyDocument(statements=[inline_pol_state_textract])
        Lambda_exec_role = iam.Role(self,"LambdaExRole",assumed_by=iam.ServicePrincipal(service='lambda.amazonaws.com'),inline_policies=[inline_pol_doc_s3,inline_pol_doc_textract],path="/")
        DocumentTextract = lambda_.Function(self,id="DocumenTextract",#runtime=lambda_.Runtime.PYTHON_3_6,role=Lambda_exec_role)
        bucket_.add_event_notification(s3.EventType.OBJECT_CREATED,s3n.LambdaDestination(DocumentTextract))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...