Updating a dynamodb GSI index directly

I am trying to update my attributes in dynamodb that i use as indexes, basically i am building an order matching system, and if an order is matched i want to change the GSI from OPEN to CLOSED

Heres the code ive written:

await dynamodb
              TableName: process.env.ORDERS_TABLE_NAME,
              Key: { id: maker.id },
              UpdateExpression: "set #status = :status, orderRate = :orderRate",
              ExpressionAttributeValues: {
                ":status": "CLOSED",
                ":orderRate": "BUY#CLOSED#300",
              ExpressionAttributeNames: {
                "#status": "status",

the orderRate is an attribute i saved as {side}#status#{rate} so an example would be BUY#OPEN#500

the orderRate is a GSI i use in the db, so i want to know if its possible to update GSI’s and if so what am i doing wrong in the code provided above because i get the error:

ERROR   ValidationException: The provided key element does not match the schema

thanks for the help

Source: Ask Javascript Questions