Skip to content

Commit e0221bd

Browse files
anajmi07athewsey
authored andcommitted
Update main.tf
1 parent 966aef3 commit e0221bd

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

infra/modules/kb-stack/main.tf

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,48 @@ resource "aws_s3_bucket_public_access_block" "kb_bucket_pab" {
1212
restrict_public_buckets = true
1313
}
1414

15+
# Access logging bucket
16+
resource "aws_s3_bucket" "access_logs" {
17+
bucket_prefix = "${var.name}-access-logs"
18+
}
19+
20+
resource "aws_s3_bucket_public_access_block" "access_logs_pab" {
21+
bucket = aws_s3_bucket.access_logs.id
22+
23+
block_public_acls = true
24+
block_public_policy = true
25+
ignore_public_acls = true
26+
restrict_public_buckets = true
27+
}
28+
29+
# Enable access logging
30+
resource "aws_s3_bucket_logging" "kb_bucket_logging" {
31+
bucket = aws_s3_bucket.kb_bucket.id
32+
33+
target_bucket = aws_s3_bucket.access_logs.id
34+
target_prefix = "access-logs/"
35+
}
36+
37+
# Lifecycle configuration
38+
resource "aws_s3_bucket_lifecycle_configuration" "kb_bucket_lifecycle" {
39+
bucket = aws_s3_bucket.kb_bucket.id
40+
41+
rule {
42+
id = "knowledge_base_lifecycle"
43+
status = "Enabled"
44+
45+
transition {
46+
days = 30
47+
storage_class = "STANDARD_IA"
48+
}
49+
50+
transition {
51+
days = 90
52+
storage_class = "GLACIER"
53+
}
54+
}
55+
}
56+
1557
# IAM Role for Bedrock
1658
resource "aws_iam_role" "bedrock_role" {
1759
name = "${var.name}-bedrock-role"

0 commit comments

Comments
 (0)