Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDB: Allow generation of custom values for hash and range key #201

Open
robhughadams opened this issue Jun 22, 2023 · 0 comments · May be fixed by #202
Open

DynamoDB: Allow generation of custom values for hash and range key #201

robhughadams opened this issue Jun 22, 2023 · 0 comments · May be fixed by #202

Comments

@robhughadams
Copy link

I'd like to be able to use the plugin to support more complex request mapping scenarios for DynamoDB.

The shorthand mapping from querystring or path works really well for simple examples, but doesn't for more complex situations. E.g. where the hash and range key in the dynamo table are concatenated values and are exposed as separate parameters on the external API.

Ideally I'd be able to generate this request template:

"RequestTemplates": {
  "application/json": {
    "Fn::Sub": [
      "{\"TableName\": \"${TableName}\",\"Key\":{\"${HashKey}\": {\"${HashAttributeType}\": \"${HashAttributeValue}\"},\"${RangeKey}\": {\"${RangeAttributeType}\": \"${RangeAttributeValue}\"}}}",
      {
        "TableName": "some-table",
        "HashKey": "Foo_Bar",
        "HashAttributeType": "S",
        "HashAttributeValue": "${input.params().path.foo}_${input.params().querystring.bar}",
        "RangeKey": "Baz_Quux",
        "RangeAttributeType": "S",
        "RangeAttributeValue": "${input.params().path.baz}_${input.params().header.quux}"
      }
    ]
  }

using this serverless yaml:

hashKey:
  keyName: id
  attributeValue: \${input.params().path.foo}_\${input.params().querystring.bar}
  attributeType: S
rangeKey:
  keyName: range
  attributeValue: \${input.params().path.baz}_\${input.params().header.quux} # Custom mapping for the attribute. Use '\${}' to escape the '$' character.
  attributeType: S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant