Skip to main content

Amazon DynamoDB

caution

Use of external data services in AWS will make charges your account. Please make sure to perform the cleanup per the notes at the bottom of the lab.

The following Lab focuses on quick deployment of Amazon DynamoDB table using Terraform and then walks through the creation of a resource with Retool Resources.

Requirements

To configure Amazon DynamoDB the following is required:

  • AWS Account with Administrative user
  • Terraform installed and configured for AWS Account

Steps

The following Terraform template available here is used to configure a simple DynamoDB table.

terraform {}
provider "aws" {
profile = "sandbox"
region = "us-west-2"
}
resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
billing_mode = "PROVISIONED"
read_capacity = 1
write_capacity = 1
hash_key = "UserId"
range_key = "GameTitle"
attribute {
name = "UserId"
type = "S"
}
attribute {
name = "GameTitle"
type = "S"
}
attribute {
name = "TopScore"
type = "N"
}
ttl {
attribute_name = "TimeToExist"
enabled = false
}
global_secondary_index {
name = "GameTitleIndex"
hash_key = "GameTitle"
range_key = "TopScore"
write_capacity = 1
read_capacity = 1
projection_type = "INCLUDE"
non_key_attributes = ["UserId"]
}
tags = {
Name = "retool-training-dynamodb-table-1"
Environment = "sandbox"
}
}
  • Create the file main.tf and place the contents into the file.
  • Initialize Terraform in the directory the main.tf.
terraform init
  • Plan the Terraform.
terraform plan
  • Run the Terraform.
terraform create
  • Within Retool Home, select Resources > Create Resource

DynamoDB1

  • Within this form, provide a name, description, AWS Region (e.g. us-east-2), AWS Access Key ID and AWS Secret Key ID.
  • The following image shows an example of it being populated. In addition select Save changes and Test connection to confirm successful connectivity.

DynamoDB2

info

NOTE: The following image shows how one can track which Retool Platform App, Mobile or Workflow is leveraging it.

DynamoDB3

Cleanup of Amazon DynamoDB

The following steps can be used to cleanup the Amazon RDS instance.

  • Delete the Resource in Retool
  • Go to Retool Home Page > Resources > (select Resource created previously) > … > Delete.
  • Destroy the DynamoDB table via Terraform
terraform destroy
...
[Enter y] y