For some strange reason, Lambda (Python3.8) is not able to connect to S3 bucket using Role. It just returns Timed Out error. It does not even throw any exception. It Times Out when this section is called
response = s3.list_buckets()
I have even checked flow log of the Lambda ENI. They are returning no-data.
However, the same setting is working in another project.
Here is the code sample:
import json
import datetime
import time
import config as cf
import boto3
import botocore
from botocore.exceptions import ClientError
def lambda_handler(event, context):
try:
# Retrieve the list of existing buckets
s3 = boto3.client('s3')
response = s3.list_buckets()
# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
print(f' {bucket["Name"]}')
except Exception as e:
print("Exception:\n" + str(e))
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Has anyone faced any such problem?
A little help/advice would be really appreciated, I have been struggling for the last 2 days and I have to submit my work.
Thanks in advance.
Cheers,
Suman