I am trying to keep a running total of data in 5 minutes increments. The logic I have is based on this tutorial:
I have a table set up and it is finished creating. It has the following keys:
Primary partition key timeStamp (String) Primary sort key thing (String)
There is no data in the table.
I am trying to following json to add/update. I am expecting that when boto3 tries to update the table if it does not find a record with the primary/secondary key values it will add one.
I am getting the following error:
An error occurred (ResourceNotFoundException) when calling the UpdateItem operation: Requested resource not found: ResourceNotFoundException Traceback (most recent call last): File "/var/task/lambda_function.py", line 44, in lambda_handler update_dynamo_event_counter('cycles.5.minutes', key1, key[0], int(val)) File "/var/task/lambda_function.py", line 15, in update_dynamo_event_counter 'thing': "a thing", File "/var/runtime/boto3/resources/factory.py", line 520, in do_action response = action(self, *args, **kwargs) File "/var/runtime/boto3/resources/action.py", line 83, in call response = getattr(parent.meta.client, operation_name)(**params) File "/var/runtime/botocore/client.py", line 312, in _api_call return self._make_api_call(operation_name, kwargs) File "/var/runtime/botocore/client.py", line 601, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the UpdateItem operation: Requested resource not found
This is my code:
def update_dynamo_event_counter(tableName, ts, t, event_count=1, dynamodb = boto3.resource(service_name='dynamodb', region_name='eu-west-1')):
table = dynamodb.Table(tableName)
hrTimeStamp = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
response = table.update_item(
Key={
'timeStamp': "123456",
'thing': "a thing",
}
)
I am passing the table name "theTable" and not the arn resource string.
table = dynamodb.Table(tableName)
. – smcstewart