4

I want to connect my AWS S3 with my AWS Lambda. I created my s3 bucket and named it xyz. While creating an event source on my AWS Lambda function, it is showing the following error

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. 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.

My Policy document for the IAM role I created for Lambda is as follows

{
"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?

3
  • 1
    Following up on the error message: Your bucket must be in the same region as the function. Have you deployed the function in the same AWS region as the bucket, or deleted the bucket and recreated it in the same AWS region as the Lambda function? (Note, after deleting a bucket, it can take up to an hour for all the other S3 regions to realize the name is available. The bucket namespace itself is global but S3 is a regional service.) Commented Sep 17, 2015 at 21:11
  • How do I know the regions of the AWS s3 and AWS lambda on the GUI? Commented Sep 18, 2015 at 6:30
  • 2
    To view the region of an Amazon S3 bucket, click on the bucket in the management console, then go to the Properties tab. The region will be displayed. To determine the region of a Lambda function, go to the Lambda console. Only the Lambda functions in the current region (based on the region pull-down menu in the top-right of the screen) will displayed. Commented Sep 19, 2015 at 0:51

1 Answer 1

9

Thanks to John's comment, I was able to resolve this issue.

This problem occurs when (clearly stated by the error message) Lambda and S3 buckets are residing in different regions.

For creating lambda in the same region as that of s3 bucket, you need to know bucket's region.

To view the region of an Amazon S3 bucket, click on the bucket in the management console, then go to the Properties tab. 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.

Once you change your region to that of s3 bucket, creating a new lambda function will solve the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.