I'm trying to update my partition key using python in aws but I can't really figure it out if it's even possible to update it?
def modifyItem(URL_ADDRESS, updateKey, updateValue):
try:
response = table.update_item(
Key={
'URL_ADDRESS': URL_ADDRESS
},
UpdateExpression='set %s = :value' % updateKey,
ExpressionAttributeValues={
':value':updateValue
},
ReturnValues='UPDATED_NEW'
)
body = {
'Operation': 'UPDATE',
'Message': 'SUCCESS',
'UpdatedAttributes': response
}
return buildResponse(200, body)
CodePudding user response:
You cannot update an item’s primary key (either its partition key or sort key). You must insert a new item and delete the old.