Has anyone encountered this Error when using the Lambda with boto3 rds execute_statement( )?
[ERROR] ParamValidationError: Parameter validation failed:
Unknown parameter in input: "formatRecordsAs", must be one of: continueAfterTimeout, database, includeResultMetadata, parameters, resourceArn, resultSetOptions, schema, secretArn, sql, transactionId
I have been using vs code to develop lambda functions locally and it works fine when using boto3:rds execute_statement( ) with the "formatRecordsAs" parameter. Here is what I have tested successful locally:
def lambda_handler(event, context):
response = execute_statement(sql)['formattedRecords']
df = pd.read_json(response)
df_string = df.to_string()
print(df_string)
def execute_statement(sql):
response = db.rds_client.execute_statement(
secretArn = db.db_secret_arn,
database = db.db_name,
resourceArn = db.db_resource_arn,
sql = sql,
formatRecordsAs='JSON'
)
return response
I was able to pass in a string as sql statement (specifically SELECT where returning response in json format is needed) using the above code on my local vs code editor. I get records returned in json format as expected. However once I paste my code to lambda, I get everything else working as expected except "formatRecordsAs".(see error code above)
When formatRecordsAs = 'JSON' is omitted, I then get successful response as I would in other settings unformatted. But I really need the returned data to be formatted in json.
To my understanding, somehow according to the error message, AWS Lambda doesn't register formatRecordsAs as a valid parameter but accept all other parameters listed in the documentation.
Please help, thanks!
boto3 in a lambda function is not full nor it is the latest version. Thus its quite common to run into the issues you report with invalid arguments, etc.
You have to bundle full boto3 with your function, for example using a layer.