feat: DynamoDB single-table Terraform module with 5 GSIs - #64
feat: DynamoDB single-table Terraform module with 5 GSIs#64maxsonferovante wants to merge 4 commits into
Conversation
- Create single_table module with composite key design: - PK/SK as main access pattern - GSI1: UUID-based lookups (Certificate by ID) - GSI2: Email-based access (Orders, Certificates, Participants) - GSI3: Product-based access (Products, Certificates, Orders) - GSI4: Success flag access (successful certificates) - GSI5: City-based access (Participants) - Update dev environment to use single_table module - Replace 4 separate DynamoDB tables with single table design
bentoluizv
left a comment
There was a problem hiding this comment.
O outputs.tf não foi atualizado junto — ainda referencia os quatro módulos que esse PR removeu do main.tf. Rodei terraform validate no head da branch e dá 8 erros de "Reference to undeclared module", nas linhas 15, 20, 26, 31, 37, 42, 48 e 53. Precisa remover esses outputs ou apontar pro module.dynamodb_single_table.
|
|
||
| # EntityType para identificação rápida do tipo | ||
| attribute { | ||
| name = "EntityType" |
There was a problem hiding this comment.
O EntityType tá declarado como attribute mas não é chave de nada — nem hash_key/range_key da tabela, nem de nenhum dos cinco GSIs. Isso quebra o apply no plan, antes de chamar a AWS:
Error: all attributes must be indexed. Unused attributes: ["EntityType"]
on ../modules/02.dynamodb/single_table/main.tf line 14
Testei o módulo contra o MiniStack variando só esse bloco: com ele dá o erro acima, sem ele a tabela sobe ACTIVE com os 5 GSIs certinhos.
Pode remover — o DynamoDB é schemaless, então a aplicação continua gravando EntityType e usando no filter_expression sem precisar declarar como atributo.
|
|
||
| # GSI5: CITY# lookups (participant city) | ||
| global_secondary_index { | ||
| name = "GSI5" |
There was a problem hiding this comment.
O GSI5 reintroduz o índice por cidade removido no #59. Dá pra tirar ele e os atributos GSI5PK/GSI5SK (:72 e :77)?
- Remove GSI5 (city-based access for participants) - Update outputs.tf to reference dynamodb_single_table module - Fix terraform validate errors (8 module reference errors) - Update comments to reflect actual GSI usage
Summary
Creates Terraform module for DynamoDB single-table design with 5 Global Secondary Indexes.
Changes
GSI Design
Related
API PR: PythonFloripa/py-certify-api
Notification PR: PythonFloripa/py-certify-notification