1 Answer
- Newest
- Most votes
- Most comments
1
It seems like your AWS Lambda function is timing out without completing its task of listing objects in an S3 bucket. This issue can be due to a few different reasons. Let's go through some steps you can take to troubleshoot and hopefully resolve the issue:
- Set the function timeout to a higher value, like 30 seconds or 1 minute, through the AWS Console or CLI.
- Ensure the Lambda function's IAM role has s3:ListBucket permission for the S3 bucket. For testing, you can use the AmazonS3ReadOnlyAccess policy but refine permissions for production use.
- Incorporate additional logging before and after the S3 list operation to identify where the function is getting stuck.
- Use the AWS CLI to test listing objects in the bucket by assuming the Lambda's IAM role, verifying the role's permissions. You can use the IAM policy simulator.
Thank you sir! I increased the time and it worked. This one answer will solve many of my issues! You other items have been documented. I truly appreciate what your effort here. Thank you!
Relevant content
- asked 5 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 5 months ago
Not related to the question of listing objects in S3, but when using Lambda, there is no need to specify IAM creds (Access Key and Secret Key). Rather, the Lambda role will be used, and it should have the required permissions, in your case to call S3.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html: AWS_ACCESS_KEY, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN – The access keys obtained from the function's execution role.