dynein /daɪ.nɪn/ is a command line interface for Amazon DynamoDB written in Rust. dynein is designed to make it simple to interact with DynamoDB tables/items from terminal.
dy get abc{"id": 123} ) over DynamoDB JSON ( {"id": {"N": "123"}} ).You can download binaries of a specific version from the releases page. For example, below instructions are example comamnds to download the latest version in each platform.
$ curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-macos.tar.gz
$ tar xzvf dynein-macos.tar.gz
$ mv dy /usr/local/bin/
$ dy --help
$ curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-macos-arm.tar.gz
$ tar xzvf dynein-macos-arm.tar.gz
$ mv dy /usr/local/bin/
$ dy --help
$ curl -O -L https://github.com/awslabs/dynein/releases/latest/download/dynein-linux.tar.gz
$ tar xzvf dynein-linux.tar.gz
$ sudo mv dy /usr/local/bin/
$ dy --help
$ brew install dynein
dynein is written in Rust, so you can build and install dynein with Cargo. To build dynein from source code you need to install Rust as a prerequisite.
$ git clone [[this_git_repository_url]]
$ cd dynein
$ cargo install --locked --path .
$ ./target/release/dy --help
You can move the binary file named "dy" to anywhere under your $PATH.
First of all, please make sure you've already configured AWS Credentials in your environment. dynein depends on aws-sdk-rust - for example ~/.aws/credentials file, IAM EC2 Instance Profile, or environment variables such as AWS_DEFAULT_REGION / AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_PROFILE.
One convenient way to check if your AWS credential configuration is ok to use dynein is to install and try to execute AWS CLI in your environment (e.g. $ aws dynamodb list-tables). Once you've configured AWS CLI, you should be ready to use dynein.
After you installed dynein you should have a binary named dy in your $PATH. The first command you can try is dy ls, which lists tables you have:
$ dy ls --all-regions
DynamoDB tables in region: us-west-2
EventData
EventUsers
* Forum
Thread
DynamoDB tables in region: us-west-1
No table in this region.
DynamoDB tables in region: us-east-2
UserBooks
Users
...
Here --all-regions option enables you to iterate over all AWS regions and list all tables for you.
Next you can try dy scan with region and table options. dy scan command executes Scan API internally to retrieve all items in the table.
$ dy scan --region us-west-2 --table Forum
Name attributes
Amazon S3 {"Category":"Amazon Web Services"}
Amazon DynamoDB {"Views":1000,"Threads":2,"Messages":4,"Category":...
Here Name is a primary key of this Forum table and attributes column contains rest attributes of each item.
You don't want to pass --region and --table everytime? Let's mark the table as "currently using" with the command dy use.
$ dy use Forum --region us-west-2
Now you can interact with the table without specifying a target.
$ dy scan
Name attributes
Amazon S3 {"Category":"Amazon Web Services"}
Amazon DynamoDB {"Threads":2,"Views":1000,"Messages":4,"Category":...
To find more features, dy help will show you complete list of available commands.
$ dy --help
dynein x.x.x
dynein is a command line tool to interact with DynamoDB tables/data using concise interface.
dynein looks for config files under $HOME/.dynein/ directory.
USAGE:
dy [OPTIONS] <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-r, --region <region> The region to use (e.g. --region us-east-1). When using DynamodB Local, use `--region
local`. You can use --region option in both top-level and subcommand-level
-t, --table <table> Target table of the operation. You can use --table option in both top-level and subcommand-
level. You can store table schema locally by executing `$ dy use`, after that
you need not to specify --table on every command
SUBCOMMANDS:
admin <sub> Admin operations such as creating/updating table or GSI
backup Take backup of a DynamoDB table using on-demand backup
bootstrap Create sample tables and load test data for bootstrapping
bwrite Put or Delete multiple items at one time, up to 25 requests. [API: BatchWriteItem]
config <sub> Manage configuration files (config.yml and cache.yml) from command line
del Delete an existing item. [API: DeleteItem]
desc Show detailed information of a table. [API: DescribeTable]
export Export items from a DynamoDB table and save them as CSV/JSON file
get Retrieve an item by specifying primary key(s). [API: GetItem]
help Prints this message or the help of the given subcommand(s)
import Import items into a DynamoDB table from CSV/JSON file
list List tables in the region. [API: ListTables]
put Create a new item, or replace an existing item. [API: PutItem]
query Retrieve items that match conditions. Partition key is required. [API: Query]
restore Restore a DynamoDB table from backup data
scan Retrieve items in a table without any condition. [API: Scan]
upd Update an existing item. [API: UpdateItem]
use Switch target table context. After you use the command you don't need to specify table every time,
but you may overwrite the target table with --table (-t) option
dynein consists of multiple layers of subcommands. For example, dy admin and dy config require you to give additional action to run.
$ dy admin --help
dy-admin x.x.x
<sub> Admin operations such as creating/updating table or GSI
USAGE:
dy admin [OPTIONS] <SUBCOMMAND>
FLAGS: ...
OPTIONS: ...
SUBCOMMANDS:
create Create new DynamoDB table or GSI. [API: CreateTable, UpdateTable]
delete Delete a DynamoDB table or GSI. [API: DeleteTable]
desc Show detailed information of a table. [API: DescribeTable]
help Prints this message or the help of the given subcommand(s)
list List tables in the region. [API: ListTables]
update Update a DynamoDB table. [API: UpdateTable etc]
By executing following command, you can create a DynamoDB table.
$ dy admin create table mytable --keys pk,S
The easiest way to get familiar with dynein and DynamoDB would be executing dy bootstrap. The bootstrap subcommand creates sample tables and automatically load sample data defined here. After that, you'll see some sample commands to demonstrate basic usage of dynein.
$ dy bootstrap
Bootstrapping - dynein will creates 4 sample tables defined here:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AppendixSampleTables.html
'ProductCatalog' - simple primary key table
Id (N)
'Forum' - simple primary key table
Name (S)
'Thread' - composite primary key table
ForumName (S)
Subject (S)
'Reply' - composite primary key table, with GSI named 'PostedBy-Message-Index'
Id (S)
ReplyDateTime (S)
...(snip logs)...
Now all tables have sample data. Try following commands to play with dynein. Enjoy!
$ dy --region us-west-2 ls
$ dy --region us-west-2 desc --table Thread
$ dy --region us-west-2 scan --table Thread
$ dy --region us-west-2 use --table Thread
$ dy scan
After you 'use' a table like above, dynein assume you're using the same region & table, which info is stored at ~/.dynein/config.yml and ~/.dynein/cache.yml
Let's move on with the 'us-west-2' region you've just 'use'd...
$ dy scan --table Forum
$ dy scan -t ProductCatalog
$ dy get -t ProductCatalog 101
$ dy query -t Reply "Amazon DynamoDB#DynamoDB Thread 2"
$ dy query -t Reply "Amazon DynamoDB#DynamoDB Thread 2" --sort-key "begins_with 2015-10"
If you're interested in other available sample tables with data, check dy bootstrap --list and pass desired target to --sample option.
Using dynein, you can create a table:
$ dy admin create table app_users --keys app_id,S user_id,S
---
name: app_users
region: us-east-1
status: CREATING
schema:
pk: app_id (S)
sk: user_id (S)
mode: OnDemand
capacity: ~
gsi: ~
lsi: ~
stream: ~
count: 0
size_bytes: 0
created_at: "2020-03-03T13:34:43+00:00"
After the table get ready (i.e. status: CREATING changed to ACTIVE), you can write-to and read-from the table.
$ dy use app_users
$ dy desc
---
name: app_users
region: us-east-1
status: ACTIVE
schema:
pk: app_id (S)
sk: user_id (S)
mode: OnDemand
capacity: ~
gsi: ~
lsi: ~
stream: ~
count: 0
size_bytes: 0
created_at: "2020-03-03T13:34:43+00:00"
$ dy put myapp 1234 --item '{"rank": 99}'
Successfully put an item to the table 'app_users'.
$ dy scan
app_id user_id attributes
myapp 1234 {"rank":99}
Similarly you can update tables with dynein.
$ dy admin update table app_users --mode provisioned --wcu 10 --rcu 25
NOTE: currently this feature is under development
Infrastracture as Code is a concept that you define code to provision "infrastructures", such as DynamoDB tables, with "declarative" way (On the other hand you can say dy admin create table and dy admin update table commands are "imperative" way).
To manage DynamoDB tables with "declarative" way, dynein provides dy admin plan and dy admin apply commands. Internally dynein executes AWS CloudFormation APIs to provision DynamoDB resources for you.
$ ls
mytable.cfn.yml
$ cat mytable.cfn.yml
Resources:
MyDDB:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
BillingMode: PAY_PER_REQUEST
(currently not available) $ dy admin plan
(currently not available) $ dy admin apply
CloudFormation manages DynamoDB tables through the resource type named AWS::DynamoDB::Table - visit the link for more information.
dy use and dy config to switch/manage contextBasically it's pretty straight forward to specify tab
$ claude mcp add dynein \
-- python -m otcore.mcp_server <graph>