DynamoDB Integration

Querying Amazon DynamoDB with Retool.

DynamoDB is Amazon's non-relational managed database. Retool connects with DynamoDB, allowing you to access your data from your internal tools.

Connecting DynamoDB

First, go to IAM and create a new user called retool-dynamodb. Only enable "programmatic access".

Click "next" to grant the account permissions. It's easiest to grant the account full DynamoDB permissions, but you can restrict permissions further. You'll need to create a new policy and attach this policy to the user. Here's an example JSON IAM policy, which you can modify to your security needs.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "dynamodb:ListTables",
                "dynamodb:DeleteItem",
                "dynamodb:ListTagsOfResource",
                "dynamodb:DescribeReservedCapacityOfferings",
                "dynamodb:DescribeTable",
                "dynamodb:GetItem",
                "dynamodb:DescribeContinuousBackups",
                "dynamodb:DescribeLimits",
                "dynamodb:BatchGetItem",
                "dynamodb:BatchWriteItem",
                "dynamodb:PutItem",
                "dynamodb:ListBackups",
                "dynamodb:Scan",
                "dynamodb:Query",
                "dynamodb:DescribeStream",
                "dynamodb:UpdateItem",
                "dynamodb:DescribeTimeToLive",
                "dynamodb:ListStreams",
                "dynamodb:DescribeGlobalTableSettings",
                "dynamodb:ListGlobalTables",
                "dynamodb:GetShardIterator",
                "dynamodb:DescribeGlobalTable",
                "dynamodb:DescribeReservedCapacity",
                "dynamodb:DescribeBackup",
                "dynamodb:GetRecords"
            ],
            "Resource": "*"
        }
    ]
}

Once you've created the user, head back to Retool. To connect to DynamoDB, you will need your AWS Access Key, Secret Key, and the region of your DynamoDB instance. Go to Resources, click Add, and select DynamoDB from the options.

Configuration screen for DynamoDB.Configuration screen for DynamoDB.

Configuration screen for DynamoDB.

After picking the region and filling out your credentials, press Save to test the connection. Now your resource will be available for queries.

Querying DynamoDB

Once your resource is set up, you can make DynamoDB queries in your applications. Create a new application or open up an existing one, and open the query editor. From the resource options, pick the newly created DynamoDB resource. Your interface will look like this.

Select the table you want to query and the type of query you want to run. We support CRUD operations on individual items, querying tables and scanning tables. You can look at the AWS DynamoDB documentation for more information on the fields.

🚧

Query results are at query1.data.Items

Dynamo query and scan type queries will return the array of results under the queryName.data.Items key!

If you want finer control over your query, you can use the JSON parameter editor to directly edit the parameters object passed to the query (with fields like TableName, etc.). This way, you can copy example queries directly from your previous applications, or the documentation.

Example: How to build a DynamoDB admin panel

In this video, you'll find a 15 minute walk through on how to build an admin panel connected to a DynamoDB instance.

We cover implementing create, read, update and delete functionality in the app.

DynamoDB query syntax can be a little cumbersome. For quick reference, here are some screenshots from the video above of specific query types.



Example putItem syntax from the video.



Example updateItem syntax using protected names from the video:



Example deleteItem syntax from the video:



Example scan operation from video:


Did this page help you?