- Configurable table name, hash key, and optional sort key
- TTL (Time To Live) for auto-expiring items
- Streams for Lambda or change tracking integration
- Point-in-time recovery (automated backups)
- Optional Global Secondary Indexes (GSIs)
- IAM policy documents for read and write permissions
- Optional deletion protection
- Full environment and owner tagging
module "document_reference_dynamodb_table" {
source = "./modules/dynamo_db"
# Table name and primary key
table_name = var.docstore_dynamodb_table_name
hash_key = "ID"
# Optional sort key
# sort_key = "created_at"
# Attribute definitions for the table and indexes
attributes = [
{
name = "ID"
type = "S"
},
{
name = "FileLocation"
type = "S"
},
{
name = "NhsNumber"
type = "S"
}
]
# Optional: enable TTL
ttl_enabled = true
ttl_attribute_name = "TTL"
# Optional: enable streams
stream_view_type = "OLD_IMAGE"
# Optional: point-in-time recovery
point_in_time_recovery_enabled = !local.is_sandbox
# Optional: global secondary indexes
global_secondary_indexes = [
{
name = "FileLocationsIndex"
hash_key = "FileLocation"
projection_type = "ALL"
},
{
name = "NhsNumberIndex"
hash_key = "NhsNumber"
projection_type = "ALL"
}
]
# Context tags
environment = var.environment
owner = var.owner
# Optional: enable deletion protection
deletion_protection_enabled = local.is_production
}
| Name | Version |
|---|---|
| aws | ~> 6.0 |
| Name | Type |
|---|---|
| aws_dynamodb_table.ndr_dynamodb_table | resource |
| aws_iam_policy.dynamodb_policy | resource |
| aws_iam_policy_document.dynamodb_read_policy | data source |
| aws_iam_policy_document.dynamodb_write_policy | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| attributes | List of nested attribute definitions. | list(map(string)) |
[] |
no |
| billing_mode | DynamoDB billing mode (e.g., PAY_PER_REQUEST). | string |
"PAY_PER_REQUEST" |
no |
| deletion_protection_enabled | Prevents table from accidental deletion. | bool |
null |
no |
| environment | Deployment environment tag used for naming and labeling (e.g., dev, prod). | string |
n/a | yes |
| global_secondary_indexes | List of optional Global Secondary Indexes. | any |
[] |
no |
| hash_key | Primary partition key for the table. | string |
null |
no |
| owner | Identifies the team or person responsible for the resource (used for tagging). | string |
n/a | yes |
| point_in_time_recovery_enabled | Enables PITR for backups. | bool |
false |
no |
| sort_key | Optional range/sort key for composite primary key. | string |
null |
no |
| stream_view_type | Type of stream view (e.g., OLD_IMAGE). | string |
null |
no |
| table_name | Name of the DynamoDB table. | string |
null |
no |
| ttl_attribute_name | Name of the TTL attribute. | string |
"" |
no |
| ttl_enabled | Whether to enable TTL (Time to Live) on items. | bool |
false |
no |
| Name | Description |
|---|---|
| dynamodb_policy | n/a |
| dynamodb_read_policy_document | n/a |
| dynamodb_stream_arn | n/a |
| dynamodb_table_arn | n/a |
| dynamodb_write_policy_document | n/a |
| table_name | n/a |