简体   繁体   English

无法将AWS S3与AWS Lambda链接

[英]Unable to link AWS S3 with AWS Lambda

I want to connect my AWS S3 with my AWS Lambda . 我想将AWS S3AWS Lambda连接 I created my s3 bucket and named it xyz . 我创建了我的s3桶并命名为xyz While creating an event source on my AWS Lambda function, it is showing the following error 在我的AWS Lambda函数上创建事件源时,它显示以下错误

There was an error creating the event source mapping: Your bucket must be in the same region as the function.

While going through this link , I found out that I needed to setup a event notification for the s3 bucket for the AWS Lambda function. 在浏览此链接时 ,我发现我需要为AWS Lambda函数设置s3存储桶的事件通知。 But I am unable to setup event notification for the s3 bucket as it is not showing settings for an AWS lambda function in the events tab of the s3 bucket's properties. 但是我无法为s3存储桶设置事件通知,因为它没有在s3存储桶属性的事件选项卡中显示AWS lambda函数的设置。

My Policy document for the IAM role I created for Lambda is as follows 我为Lambda创建的IAM角色的策略文档如下

{
"Version": "VersionNumber",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "logs:CreateLogGroup",
            "logs:CreateLogStream",
            "logs:PutLogEvents"
        ],
        "Resource": "arn:aws:logs:*:*:*"
    },
    {
        "Effect": "Allow",
        "Action": [
            "s3:GetObject",
            "s3:PutObject"
        ],
        "Resource": [
            "arn:aws:s3:::xyz/*"
        ]
    }
   ]
 }

Can somebody let me know why I am unable to create an event for AWS Lambda for an operation on s3 bucket? 有人可以告诉我为什么我无法为s3存储桶上的操作创建AWS Lambda事件吗?

Thanks to John's comment, I was able to resolve this issue. 感谢John的评论,我能够解决这个问题。

This problem occurs when (clearly stated by the error message) Lambda and S3 buckets are residing in different regions. 当(由错误消息明确说明)Lambda和S3存储桶驻留在不同区域时会发生此问题。

For creating lambda in the same region as that of s3 bucket, you need to know bucket's region. 要在与s3 bucket相同的区域中创建lambda,您需要知道bucket的区域。

To view the region of an Amazon S3 bucket, click on the bucket in the management console, then go to the Properties tab. 要查看Amazon S3存储桶的区域,请单击管理控制台中的存储桶,然后转到“属性”选项卡。 The region will be displayed 将显示该区域

Now that you know your target region. 现在您已了解目标区域。 You can just switch to that region, in aws console, by selecting a region from the dropdown selection menu on top right corner just before Support menu. 您可以在aws控制台中切换到该区域,方法是在“ Support菜单之前的右上角的下拉选择菜单中选择一个区域。

Once you change your region to that of s3 bucket, creating a new lambda function will solve the issue. 将区域更改为s3存储区后,创建新的lambda函数将解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM