Skip to content

Commit b05826e

Browse files
authored
Move audit log table to terraform (#222)
1 parent 1d36fa5 commit b05826e

File tree

4 files changed

+56
-37
lines changed

4 files changed

+56
-37
lines changed

cloudformation/logs.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

cloudformation/main.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ Resources:
8585
SqsQueueArn: !Sub "arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:infra-core-api-sqs"
8686
LinkryKvArn: !GetAtt LinkryRecordsCloudfrontStore.Arn
8787

88-
AppLogGroups:
89-
Type: AWS::Serverless::Application
90-
Properties:
91-
Location: ./logs.yml
92-
9388
LinkryRecordSetv4:
9489
Condition: IsDev
9590
Type: AWS::Route53::RecordSet
@@ -218,8 +213,6 @@ Resources:
218213

219214
AppApiLambdaFunction:
220215
Type: AWS::Serverless::Function
221-
DependsOn:
222-
- AppLogGroups
223216
Properties:
224217
Architectures: [arm64]
225218
CodeUri: ../dist/lambda
@@ -261,8 +254,6 @@ Resources:
261254

262255
AppSqsLambdaFunction:
263256
Type: AWS::Serverless::Function
264-
DependsOn:
265-
- AppLogGroups
266257
Properties:
267258
Architectures: [arm64]
268259
CodeUri: ../dist/sqsConsumer

terraform/envs/prod/main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,31 @@ module "sqs_queues" {
4949
source = "../../modules/sqs"
5050
resource_prefix = var.ProjectId
5151
}
52+
53+
import {
54+
to = aws_dynamodb_table.app_audit_log
55+
id = "${var.ProjectId}-audit-log"
56+
}
57+
58+
resource "aws_dynamodb_table" "app_audit_log" {
59+
billing_mode = "PAY_PER_REQUEST"
60+
name = "${var.ProjectId}-audit-log"
61+
deletion_protection_enabled = true
62+
hash_key = "module"
63+
range_key = "createdAt"
64+
point_in_time_recovery {
65+
enabled = true
66+
}
67+
attribute {
68+
name = "module"
69+
type = "S"
70+
}
71+
attribute {
72+
name = "createdAt"
73+
type = "N"
74+
}
75+
ttl {
76+
attribute_name = "expiresAt"
77+
enabled = true
78+
}
79+
}

terraform/envs/qa/main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,31 @@ module "sqs_queues" {
3636
source = "../../modules/sqs"
3737
resource_prefix = var.ProjectId
3838
}
39+
40+
import {
41+
to = aws_dynamodb_table.app_audit_log
42+
id = "${var.ProjectId}-audit-log"
43+
}
44+
45+
resource "aws_dynamodb_table" "app_audit_log" {
46+
billing_mode = "PAY_PER_REQUEST"
47+
name = "${var.ProjectId}-audit-log"
48+
deletion_protection_enabled = true
49+
hash_key = "module"
50+
range_key = "createdAt"
51+
point_in_time_recovery {
52+
enabled = true
53+
}
54+
attribute {
55+
name = "module"
56+
type = "S"
57+
}
58+
attribute {
59+
name = "createdAt"
60+
type = "N"
61+
}
62+
ttl {
63+
attribute_name = "expiresAt"
64+
enabled = true
65+
}
66+
}

0 commit comments

Comments
 (0)