I am trying to use this AWS Lambda to get results from an Amazon Athena query.
This is the Lambda function:
import boto3
# Query string to execute
query = 'SELECT DISTINCT awsaccountid, digeststarttime FROM smxtech.cloudtrail_digest'
# Database to execute the query against
DATABASE = 'xtech'
# Output location for query results
output='s3://xtech-destination/'
def lambda_handler(event, context):
# Initiate the Boto3 Client
client = boto3.client('athena')
# Start the query execution
response = client.start_query_execution(
QueryString=query,
QueryExecutionContext={
'Database': DATABASE
},
ResultConfiguration={
'OutputLocation': output
}
)
# Return response after starting the query execution
return response
I get an error:
{
"QueryExecutionId": "6e9fa646-d8e2-4d11-b61f-579091f1a714",
"ResponseMetadata": {
"RequestId": "704e1467-3c8a-46c6-8cfa-04b8bf34bc6c",
"HTTPStatusCode": 200,
"HTTPHeaders": {
"date": "Sun, 05 Feb 2023 02:13:18 GMT",
"content-type": "application/x-amz-json-1.1",
"content-length": "59",
"connection": "keep-alive",
"x-amzn-requestid": "704e1467-3c8a-46c6-8cfa-04b8bf34bc6c"
},
"RetryAttempts": 0
}
}
Does anyone know how to resolve this error?