I am trying to conditionally update an item in DynamoDB using the following code:
from boto.dynamodb2.table import Table
conn = get_layer1_ddb_connection()
values_table = Table(table_name, connection=conn)
attrs = { 'values' : new_values,
'version' : existing_item['version'] + 1}
condition_expression = 'version = :v'
values_table.update_item(table_name, key=customer_id, attribute_updates=attrs, condition_expression=condition_expression, expression_attribute_values={':v': existing_item['version'],}, return_values='ALL_OLD',)
where, layer1 connection is created like this:
from boto.dynamodb2.layer1 import DynamoDBConnection
def get_layer1_ddb_connection(self):
return DynamoDBConnection(region=self.region, aws_access_key_id=self.creds[CRED_ACCESS_KEY], aws_secret_access_key=self.creds[CRED_SECRET_KEY])
self.region
is of type RegionInfo and self.creds have always worked perfectly for other high level API calls.
This is what worked for me: