1

In one of my AWS DynamoDB tables I have several items that require an update within in a pipeline. The following json shows an item in the AWS DynamoDB table:

{
  "DeploymentConfigs": {
    "L": [
      {
        "M": {
          "Config": {
            "M": {
              "Name": {
                "S": "batch-komo"
              },
              "Replicas": {
                "N": "3"
              }
            }
          }
        }
      },
      {
        "M": {
          "Config": {
            "M": {
              "Name": {
                "S": "online-komo"
              },
              "Replicas": {
                "N": "3"
              }
            }
          }
        }
      }
    ]
  },
  "environment": {
    "S": "komo-claimcenter"
  }
}

How can update an object in DeploymentConfigs? Primary partition key is environment.

E.g. the object

{
        "M": {
          "Config": {
            "M": {
              "Name": {
                "S": "batch-komo"
              },
              "Replicas": {
                "N": "3"
              }
            }
          }
        }
}

shall be updated to

   {
        "M": {
          "Config": {
            "M": {
              "Name": {
                "S": "batch-komo"
              },
              "Replicas": {
                "N": "5"
              }
            }
          }
        }
 }

I do not know to achieve in the AWS CLI.

1
  • Did you manage to find a solution for this? Commented Feb 2, 2022 at 1:05

1 Answer 1

2

To update a nested part inside an item, you use an UpdateExpression with an attribute path. For example, SET DeploymentConfigs[0].Config.Replicas = :val.

The problem, however, is that your top-level attribute DeploymentConfigs is a list, so to modify one of its items, you need to know in index (in this example 0). If you don't know the index you have a problem - there is no way to "modify the list item which has name='batch-komo'" or something like that... If you need to do something like this, you have to read the entire top-level attribute, modify it in the client, and write it (or just the small change, now that you know the index) back.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.