Timestream error: ResourceNotFoundException

1

My lambda function is returning 'ResourceNotFoundException' error while trying to write into timestream table. Below is the full error statement:

Error writing data to Timestream: An error occurred (ResourceNotFoundException) when calling the WriteRecords operation: The table arn:aws:timestream:eu-west-1:xxxxxxxxx:database/timestreamdb1/table/timestreamdb1_table does not exist

Both the database and the table exist and I can display the table through aws cli. Also, the lambda function have IAM role that allows timestream:WriteRecords and timestream:DescribeEndpoints Please, what could be the issue?

asked 7 months ago480 views
3 Answers
0

Hi bayoojo1,

One cause of "ResourceNotFoundException" could be if the region is set incorrectly on the AWS SDK client if the Lambda function is in another region.

I'm assuming the Timestream database is in eu-west-1 based on the ARN provided. Can you confirm the Lambda function is in eu-west-1? Also, if you are using the AWSK SDK, ensure the SDK client is set to eu-west-1 (this is done automatically if the Lambda function is in eu-west-1).

AWS
tadhg_o
answered 7 months ago
  • Hi @tadhg_o,

    Both the Timestream and the lambda function are in same region - eu-west-1.

  • @bayoojo1, Are you passing in the full ARN for database and table names? I tested and received the same error when using the full ARN's. When I used just the database and table name, the write_records was successful. Can you test using just the table and database name such as timestreamdb1_table for the table name?

    For example, my database is "TestDB" and table name is "DevOpsMulti"

    response = timestream.write_records( DatabaseName='TestDB', TableName='DevOpsMulti', Records=[record_data] )

0

@tadhg_o, I think the solution is getting closer! I did as you said by using only the database and table name without the full arn and I got the below error: Error writing data to Timestream: An error occurred (RejectedRecordsException) when calling the WriteRecords operation: One or more records have been rejected.

Below is the function to write into the timestream db and I guess I'm making a mistake in the format and arrangement. For instance, I want both x_axis and y_axis to be my MeasureValue. Can I include more than one measure value and how do I arrange it?

def write_to_timestream(x_axis, y_axis, total_velocity, device_id, time):
    try:
        # Format the record
        record = {
            'Time': time.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3],  # Format time as specified
            'Dimensions': [{'Name': 'device_id', 'Value': device_id}],
            'MeasureName': 'x_axis',
            'MeasureValue': str(x_axis),
            'MeasureValueType': 'DOUBLE',
            'TimeUnit': 'MILLISECONDS'
        }
answered 7 months ago
0

The ResourceNotFoundException error indicates that the table specified in the Lambda function does not exist in Timestream, even though you can see it through the AWS CLI. Can you check the following ?

  • Make sure the IAM role attached to the Lambda function has the necessary permissions to access Timestream. The error suggests it may be missing some permissions.
  • Double check that the table ARN specified in the Lambda code exactly matches the ARN of the table when you describe it through the CLI. Even a small difference could cause this error.
  • Try running the Timestream WriteRecords API call directly from the CLI using the AWS CLI or SDK instead of through Lambda. This will eliminate Lambda or IAM issues as a potential cause
  • Check the CloudWatch logs for the Lambda function for any additional error details. Sometimes a nested cause is provided
  • Ensure the database and table specified are in the ACTIVE state and have not been deleted outside of the Lambda function's execution window.
  • If the direct API call or CLI command works but not the Lambda function, then it likely points to a permission or configuration issue between Timestream and the IAM role/policy attached to the Lambda function.
profile picture
EXPERT
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions