'@tables-indexes
Defines Global Secondary Indexes for your project’s DynamoDB tables. @tables-indexes
should only ever be paired with @tables
.
ℹ️ As of Architect v9.4,
@tables-indexes
should be used in place of@indexes
.@indexes
will be superseded in a future Arc release.
Recommended Resources
DynamoDB is a powerful database, though different from both SQL and NoSQL databases. It is highly recommended to dig into Amazon’s resources to familiarize yourself with it:
- DynamoDB Core Components (start here!)
- Global Secondary Indexes in DynamoDB
- Amazon’s full DynamoDB documentation
Syntax
@tables-indexes
is a feature subset of@tables
; as such, the names of your declared indexes must match those of your@tables
- Otherwise, the basic syntax for defining
@tables-indexes
primary keys is the same as@tables
:- Partition key, defined by a
*
, is required - Sort key, defined by
**
, is optional - Currently only
*String
,**String
,*Number
and**Number
are supported
- Partition key, defined by a
- An optional
name
property can be provided to explicitly name the index. This is helpful when querying the index with the AWS SDK as you know what to pass to theIndexName
query parameter
Example
The following app.arc
file defines a DynamoDB table with two Global Secondary Indexes:
arc
@app
testapp
@tables
accounts
accountID *String
@tables-indexes
accounts
email *String
name byEmail
accounts
created *String
name byDate
json
{
"app": "testapp",
"tables": [
{ "accounts": { "accountID": "*String" } }
],
"tables-indexes": [
{ "accounts": { "email": "*String", "name": "byEmail" } },
{ "accounts": { "created": "*String", "name": "byDate" } }
]
}
yaml
---
app: testapp
tables:
- accounts:
accountID: "*String"
tables-indexes:
- accounts:
- email: "*String"
- name: "byEmail"
- accounts:
- created: "*String"
- name: "byDate"