-1

I have an aws lambda function to create an s3 bucket. I have written this using python 3.6

Here's my code:

import boto3

def lambda_handler(event, context):
    client = boto3.client('s3')
    return client.list_buckets()

And I have set the timeout value as 20s and increased the memory to 512mb as well.

I have attached AmazonS3FullAccess as well to the IAM role of lambda. But I get the following error:

{ "errorMessage": "2021-06-18T16:49:19.237Z 1a33460c-8d7e-45f1-8601-c5b01290e439 Task timed out after 20.02 seconds" }

Why am I getting this error? Can someone help me please?

Jananath Banuka
  • 2,951
  • 8
  • 57
  • 105

1 Answers1

1

As per the MarkB's suggestion, the issue was with the lambda function bound to a vpc. If Lambda function configured to run inside a VPC you should make sure that it has access to S3. Can be achieved by configuring an S3 endpoint in the VPC, or you have configured it to run in a subnet with a route to a NAT Gateway

Jananath Banuka
  • 2,951
  • 8
  • 57
  • 105