Skip to content

Commit a4779df

Browse files
authored
CCM-11442: Add terraform resources for DDB tables (#97)
* CCM-11228: Add terraform resources for DDB tables * CCM-11228: Enable point-in-time recovery for DynamoDB tables * CCM-11442: Add TTL fields to ddb config * CCM-11228: Remove redundant attribute blocks for ttl field
1 parent 90a376f commit a4779df

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
resource "aws_dynamodb_table" "letters" {
2+
name = "${local.csi}-letters"
3+
billing_mode = "PAY_PER_REQUEST"
4+
5+
hash_key = "supplierId"
6+
range_key = "id"
7+
8+
ttl {
9+
attribute_name = "ttl"
10+
enabled = true
11+
}
12+
13+
global_secondary_index {
14+
name = "supplierStatus-index"
15+
hash_key = "supplierStatus"
16+
range_key = "id"
17+
projection_type = "ALL"
18+
}
19+
20+
attribute {
21+
name = "id"
22+
type = "string"
23+
}
24+
25+
attribute {
26+
name = "supplierId"
27+
type = "string"
28+
}
29+
30+
attribute {
31+
name = "supplierStatus"
32+
type = "string"
33+
}
34+
35+
point_in_time_recovery {
36+
enabled = true
37+
}
38+
39+
tags = var.default_tags
40+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "aws_dynamodb_table" "mi" {
2+
name = "${local.csi}-mi"
3+
billing_mode = "PAY_PER_REQUEST"
4+
5+
hash_key = "supplierId"
6+
range_key = "id"
7+
8+
ttl {
9+
attribute_name = "ttl"
10+
enabled = true
11+
}
12+
13+
attribute {
14+
name = "id"
15+
type = "string"
16+
}
17+
18+
attribute {
19+
name = "supplierId"
20+
type = "string"
21+
}
22+
23+
point_in_time_recovery {
24+
enabled = true
25+
}
26+
27+
tags = var.default_tags
28+
}

infrastructure/terraform/components/api/module_lambda_get_letters.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module "get_letters" {
3636
log_subscription_role_arn = local.acct.log_subscription_role_arn
3737

3838
lambda_env_vars = {
39+
LETTERS_TABLE_NAME = aws_dynamodb_table.letters.name
3940
}
4041
}
4142

@@ -53,4 +54,24 @@ data "aws_iam_policy_document" "get_letters_lambda" {
5354
module.kms.key_arn, ## Requires shared kms module
5455
]
5556
}
57+
58+
statement {
59+
sid = "AllowDynamoDBAccess"
60+
effect = "Allow"
61+
62+
actions = [
63+
"dynamodb:BatchGetItem",
64+
"dynamodb:BatchWriteItem",
65+
"dynamodb:DeleteItem",
66+
"dynamodb:GetItem",
67+
"dynamodb:PutItem",
68+
"dynamodb:Query",
69+
"dynamodb:Scan",
70+
"dynamodb:UpdateItem",
71+
]
72+
73+
resources = [
74+
aws_dynamodb_table.letters.arn,
75+
]
76+
}
5677
}

0 commit comments

Comments
 (0)