Category: Datasources
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How to Pass Parameters to a Dynamodb Putitem Query with a Composite Key in Appsmith

Issue

As I try to pass parameters to the PutItem query in DynamoDB, I am unable to pass a compound key based on two fields. I have tried using different escape and concat operations but with no success. My DynamoDB table uses a compound key with Item1 as partition key and Item2 as sort key.

Resolution

When working with the DynamoDB PutItem action in Appsmith, you can pass dynamic values from widgets (such as inputs) using Appsmith’s mustache ({{ }}) template syntax. This works for both simple attributes and composite (partition + sort) keys.

This article explains how to correctly pass parameters when your DynamoDB table uses a composite key, for example:

  • Partition key: Item1
  • Sort key: Item2

Passing a Single Dynamic Value

For a single attribute, replace hardcoded values with a widget reference:

"S": "{{ Input1.text }}"

This allows the value to be resolved dynamically at runtime.

Passing a Composite (Compound) Key

If your DynamoDB table requires a composite key, each key must still be provided separately in the Item object. However, in some designs, you may intentionally combine two widget values into a single string (for example, Item1#Item2) before storing it.

You can do this using JavaScript string concatenation inside mustache bindings:

"Item1": {
  "S": "{{ Input1.text + '#' + Input2.text }}"
}

And then define the sort key independently:

"Item2": {
  "S": "{{ Input2.text }}"
}

This approach allows you to:

  • Build compound identifiers dynamically
  • Pass user input safely into DynamoDB
  • Avoid hardcoding values in the query body