Amazon DynamoDB Component
Create, update, fetch, or delete items in an Amazon (AWS) DynamoDB database
Component key: aws-dynamodb
Description
Amazon DynamoDB is a key-value and document database from Amazon Web Services. The Amazon DynamoDB component allows you to create, read, update, or delete objects (items) within an Amazon DynamoDB database.
Connections
DynamoDB Access Key and Secret
An AWS IAM access key pair is required to interact with Amazon DynamoDB. Make sure that the key pair you generate in AWS has proper permissions to the DynamoDB resources you want to access. Read more about DynamoDB IAM actions in the AWS docs.
Input | Notes | Example |
---|---|---|
Access Key ID string / Required accessKeyId | An AWS IAM Access Key ID | AKIAIOSFODNN7EXAMPLE |
Secret Access Key password / Required secretAccessKey | An AWS IAM Secret Access Key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
AWS Role ARN
To enable the IAM role authentication begin by logging into the AWS Console and navigate to Identity and Access Management (IAM).
To create an ARN user and generate credentials:
- Navigate to Users and select Create User.
- Provide a User name and check the box providing them user access to the AWS Managment Console if needed.
- Once completed with the User creation, copy the ARN provided in the summary for a later step.
- To obtain the ARN for an existing User, click on the designated username from the Users page and the ARN will be provided in the summary section.
- From the summary section, select Create access key
- Select Third-party service as the access key type and select next.
- Set a description and select create access key.
- Copy the Access Key and Secret access key and enter those into the connection configuration of your integration along with the ARN.
To create and assign a user a role:
- Navigate to Roles and select Create Role.
- Select Custom Trust Policy for the Trusted entity types
- Copy the following statement into the statement console. Making sure to replace the ARN with the user's actual ARN from the previous section
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "ARN"
},
"Action": "sts:AssumeRole"
}
]
}
- When adding permissions provide the AmazonDynamoDBFullAccess permission
- Complete remaining steps and select Create Role
Input | Notes | Example |
---|---|---|
Access Key ID string / Required accessKeyId | An AWS IAM Access Key ID | AKIAIOSFODNN7EXAMPLE |
Role ARN string / Required roleARN | An AWS IAM Role ARN | arn:aws:iam::OtherAccount-ID:role/assumed-role-name |
Secret Access Key password / Required secretAccessKey | An AWS IAM Secret Access Key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
Actions
Create Table
Create a new DynamoDB Table | key: createTable
Input | Default | Notes | Example |
---|---|---|---|
Attribute Definition code / Required attributeDefinition | For each list item, provide a javascript object containing an attribute name, and an attribute type. The attribute type must be in the format that DynamoDB uses: N = number, S = string, L = Array etc... | ||
Connection connection / Required awsConnection | |||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 | |
Billing Mode string / Required billingMode | PROVISIONED | Select the item that represents your desired billing mode. | |
Key Schema code / Required keySchema | For each list item, provide a javascript object containing an attribute name, and a key type. The key type can either be a HASH or a RANGE key. | ||
Read Capacity Units string / Required readCapacityUnits | 5 | One read capacity unit represents one strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB in size. | 6000 |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers | |
Write Capacity Units string / Required writeCapacityUnits | 5 | One write capacity unit represents one write per second for an item up to 1 KB in size. If you need to write an item that is larger than 1 KB, DynamoDB must consume additional write capacity units. | 6000 |
Example Payload for Create Table
{
"data": {
"$metadata": {},
"TableDescription": {
"KeySchema": [],
"ItemCount": 0,
"TableName": "example",
"TableArn": "example",
"TableSizeBytes": 0,
"TableStatus": "CREATING"
}
}
}
Delete Item
Delete an item from a DynamoDB database | key: deleteItem
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Condition Expression string conditionExpression | Price > :limit | |
Expression Attribute Values string Key Value List expressionAttributeValues | Expression attribute values in Amazon DynamoDB are substitutes for the actual values that you want to compare—values that you might not know until runtime. An expression attribute value must begin with a colon (:) and be followed by one or more alphanumeric characters. | |
Expression Attribute Value Types string Key Value List expressionAttributeValueTypes | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | |
Range / Sort Key Value string rangeKeyValue | The value of the optional range key (sort key) to match. This is required if your table has a range key. | Acme Inc |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Hash / Primary Key Value string / Required value | The value of the hash key (primary key) to match | cust_1234 |
Delete Table
Delete an existing DynamoDB Table | key: deleteTable
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Example Payload for Delete Table
{
"data": {
"$metadata": {},
"TableDescription": {
"AttributeDefinitions": [],
"KeySchema": [],
"ItemCount": 0,
"TableName": "example",
"TableArn": "example",
"TableSizeBytes": 0,
"TableStatus": "DELETING"
}
}
}
Describe Table
Fetch metadata about an existing DynamoDB Table | key: describeTable
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Example Payload for Describe Table
{
"data": {
"$metadata": {},
"Table": {
"AttributeDefinitions": [],
"KeySchema": [],
"ItemCount": 0,
"TableName": "example",
"TableArn": "example",
"TableSizeBytes": 0,
"TableStatus": "ACTIVE"
}
}
}
Get Item
Retrieve an item from a DynamoDB database | key: getItem
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Range / Sort Key Value string rangeKeyValue | The value of the optional range key (sort key) to match. This is required if your table has a range key. | Acme Inc |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Hash / Primary Key Value string / Required value | The value of the hash key (primary key) to match | cust_1234 |
Example Payload for Get Item
{
"data": {
"result": {
"$metadata": {},
"Item": {}
},
"found": true
}
}
List Tables
List all DynamoDB Tables | key: listTables
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Example Payload for List Tables
{
"data": {
"result": {
"$metadata": {},
"TableNames": [
"Table1",
"Table2"
]
},
"found": true
}
}
Query Items
Query a DynamoDB table | key: queryItems
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required awsConnection | |||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 | |
Debug boolean debug | false | Enable debug mode to log additional information. | |
Expression Attribute Values string Key Value List expressionAttributeValues | Expression attribute values in Amazon DynamoDB are substitutes for the actual values that you want to compare—values that you might not know until runtime. An expression attribute value must begin with a colon (:) and be followed by one or more alphanumeric characters. | ||
Expression Attribute Value Types string Key Value List expressionAttributeValueTypes | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | ||
Filter Expression string filterExpression | The filter expression for the query. | contains (Subtitle, :topic) | |
Key Condition Expression string keyConditionExpression | The key condition expression for the query. | Season = :s and Episode > :e | |
Query Parameters string Key Value List queryParameters | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | ||
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Raw Request
Execute single PartiQL statements. | key: rawRequest
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required awsConnection | |||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 | |
Debug boolean debug | false | Enable debug mode to log additional information. | |
Parameters code parameters | The parameters for the PartiQL statement, if any. | ||
Query Parameters string Key Value List queryParameters | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | ||
Statement string / Required statement | The PartiQL statement representing the operation to run. | INSERT INTO Flowers value {'Name':?} |
Update Item
Update an existing item in a DynamoDB database | key: updateItem
Input | Notes | Example |
---|---|---|
Connection connection / Required awsConnection | ||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 |
Condition Expression string conditionExpression | Price > :limit | |
Update Expression string / Required query | An update expression specifies how UpdateItem will modify the attributes of an item. For example, setting a scalar value or removing elements from a list or a map. | set Title = :t, Subtitle = :s' |
Expression Attribute Values string / Required Key Value List queryParams | Expression attribute values in Amazon DynamoDB are substitutes for the actual values that you want to compare—values that you might not know until runtime. An expression attribute value must begin with a colon (:) and be followed by one or more alphanumeric characters. | |
Expression Attribute Value Types string / Required Key Value List queryParamTypes | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | |
Range / Sort Key Value string rangeKeyValue | The value of the optional range key (sort key) to match. This is required if your table has a range key. | Acme Inc |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
Hash / Primary Key Value string / Required value | The value of the hash key (primary key) to match | cust_1234 |
Upsert Item
Creates a new item, or replaces an existing item with a new item | key: createItem
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required awsConnection | |||
AWS Region string awsRegion | AWS provides services in multiple regions, like us-west-2 or eu-west-1. | us-east-1 | |
Condition Expression string conditionExpression | Price > :limit | ||
Expression Attribute Values string Key Value List expressionAttributeValues | Expression attribute values in Amazon DynamoDB are substitutes for the actual values that you want to compare—values that you might not know until runtime. An expression attribute value must begin with a colon (:) and be followed by one or more alphanumeric characters. | ||
Expression Attribute Value Types string Key Value List expressionAttributeValueTypes | The DynamoDB data type for each query param. You must specify a type for each Expression Attribute Value you provided. | ||
Value string / Required Key Value List item | key | Provide a key value record to be inserted into the specified table. | |
Value Types string / Required Key Value List itemTypes | For each item in the list, provide the datatype corresponding to the input item. | N | |
Table Name string / Required tableName | Provide the name of the table you would like to interact with. | Customers |
You must specify a datatype alongside each property you insert.
Prismatic will attempt to coerce the inputs you provide to the correct type upon execution.
You can specify the datatype of your input with the Value Type
input on the create and update item actions.
Be sure to pass the correct format into the input, below is a list of types that DynamoDB will expect.
S = string, N = number, B = buffer, BOOL = boolean, M = map/object, L = array, SS = string set, NS = number set, BS = buffer set