-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdynamodb.tf
More file actions
32 lines (26 loc) · 853 Bytes
/
dynamodb.tf
File metadata and controls
32 lines (26 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
resource "aws_dynamodb_table" "dynamodb_table" {
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.project_name}-${var.environment}-${var.table_name_suffix}"
billing_mode = "PAY_PER_REQUEST"
hash_key = var.partition_key
attribute {
name = var.partition_key
type = var.partition_key_type
}
dynamic "attribute" {
for_each = var.sort_key != null ? [1] : []
content {
name = var.sort_key
type = var.sort_key_type
}
}
range_key = var.sort_key != null ? var.sort_key : null
server_side_encryption {
enabled = true
kms_key_arn = aws_kms_key.dynamodb_cmk.arn
}
#checkov:skip=CKV_AWS_28: Point-in-time recovery is enabled only for production environments
point_in_time_recovery {
enabled = var.environment == "prod"
}
tags = var.tags
}