aws-samples / aws-samples/aws-aurora-serverless-data-api-sam

Lambda Times Out - execute_statement

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
112
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Using Lambda to access Aurora Serverless using these commands raise the following error:
"Task timed out after 7.01 seconds"
- I am only retrieving 3 rows so data size is not the issue
- I have tried longer timeout periods (upto 15 mins)
- I have also tested connectivity with my Aurora Serverless (VPC) using AWS-CLI(EC2 Instance) commands from within the VPC.
- The Security Group for Aurora Cluster allows all TCP traffic from within VPC

What I have understood so far is that the "execute_statement" function does not stops execution itself. Which leads to timeout of Lambda. Still confused how to resolve this issue.

`
import json
import boto3
import os
rds_client = boto3.client('rds-data')
db_cluster_arn = str(os.environ['DBClusterArn'])
secrets_arn = str(os.environ['SecretsArn'])
db_name = str(os.environ['DatabaseName'])
schema = str(os.environ['DatabaseName'])

def execute_statement(sql):
response = rds_client.batch_execute_statement(
secretArn = secrets_arn,
database = db_name,
resourceArn = db_cluster_arn,
sql = sql
)
return response

def lambda_handler(event, context):
response = execute_statement(f"select * from EmployeesTest")
print(response['records'])
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.