in order to look up userIDs by username or wallet address efficiently, we need a couple global secondary indexes. these will let us query by attribute instead of scanning the entire table.
Details
terraform validate and terraform fmt and terraform plan
note: learned that validate only checks the syntax. we should run plan to make sure DynamoDB-specific requirements are met
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
services/terraform/dynamodb.tf | ||
---|---|---|
182 ↗ | (On Diff #15000) | Are we really KEYS_ONLY? In this case, you can search for a username key only without projection for attributes, e.g. query for the only purpose: if the certain key exists in the table. |
services/terraform/dynamodb.tf | ||
---|---|---|
166–191 ↗ | (On Diff #15000) | Maybe I'm missing something, but according to the docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table#global_secondary_index
But both username and walletAddress aren't defined as attributes of identity-users. Could you explain how this works? |
services/terraform/dynamodb.tf | ||
---|---|---|
166–191 ↗ | (On Diff #15000) | good catch varun@varuns-MacBook-Pro terraform % terraform plan ╷ │ Error: 1 error occurred: │ * all indexes must match a defined attribute. Unmatched indexes: ["username" "walletAddress"] │ │ │ │ with aws_dynamodb_table.identity-users, │ on dynamodb.tf line 166, in resource "aws_dynamodb_table" "identity-users": │ 166: resource "aws_dynamodb_table" "identity-users" { │ i'll update this now |
182 ↗ | (On Diff #15000) | Yeah this is intentional. The purpose of this index is to look up the primary key of the table (userID) with the username attribute. We don't need to pull other attributes into the index. |
yeah it's a backlogged task https://linear.app/comm/issue/ENG-1392/add-terraform-pre-commit-hook-to-github-actions-buildkite