Support Questions

Find answers, ask questions, and share your expertise

DynamoDB table scan

avatar
New Contributor

Greetings,

 

I have a dynamodb table and I need to scan this table and I need to use a filter expression. When I run the command from the prompt I receive the result that I want, but when I run the command with ExecuteProcess, I'm having trouble with the expression-attribute-values parameter.

 

When I run the command I receive the following error:

 

 

 

usage: 
Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: :value', =

 

 

 

 

 

aws dynamodb scan --table-name myTable --filter-expression "url = :value" --expression-attribute-values '{":value":{"S":"https://www.google.com"}}'

 

 

 

 

My processor configuration :

 

joaoclaudio_0-1636132870549.png

Anyone could help me?

1 REPLY 1

avatar
New Contributor

I did a workaround and run this command using a bash script. When I try to send this json as a parameter I had the same error. I imagine that is not a problem from Nifi, but something related to passing a json to a bash script. In my processor I run the script and as parameter the name of my function and the url to search. To solve the problem of the json I create a temporary file with the data. 

 

#!/bin/bash
TABLE="myTable"
URL=$2
FILTER_EXPRESSION="url = :value"
EXPRESSION_ATTR="{\":value\":{\"S\":\"$URL\"}}"

endpoint () {
    echo $EXPRESSION_ATTR > /tmp/expression.json
    aws dynamodb scan --table-name $TABLE \
    --filter-expression "$FILTER_EXPRESSION" \
    --expression-attribute-values file:///tmp/expression.json \
    rm -f /tmp/expression.json
}

$1