Skip to content

Commit 1b63d33

Browse files
author
kfc-manager
committed
fix: FluentBit not creating CloudWatch log group
1 parent a758473 commit 1b63d33

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

main.tf

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -371,32 +371,9 @@ resource "aws_iam_role" "log" {
371371
tags = var.tags
372372
}
373373

374-
data "aws_iam_policy_document" "log" {
375-
statement {
376-
effect = "Allow"
377-
378-
actions = [
379-
"logs:PutLogEvents",
380-
"logs:Describe*",
381-
"logs:CreateLogStream",
382-
"logs:CreateLogGroup",
383-
"logs:PutRetentionPolicy"
384-
]
385-
386-
resources = ["*"]
387-
}
388-
}
389-
390-
resource "aws_iam_policy" "log" {
391-
policy = data.aws_iam_policy_document.log.json
392-
name = "${var.identifier}-FluentBitCloudWatch"
393-
394-
tags = var.tags
395-
}
396-
397374
resource "aws_iam_role_policy_attachment" "log" {
398375
role = aws_iam_role.log.name
399-
policy_arn = aws_iam_policy.log.arn
376+
policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
400377
}
401378

402379
# kubernetes provider used to create this resource
@@ -426,10 +403,47 @@ resource "helm_release" "log" {
426403
name = "aws-fluent-bit"
427404
namespace = kubernetes_namespace.log.id
428405

406+
set {
407+
name = "serviceAccount.name"
408+
value = "fluentbit-sa"
409+
}
410+
411+
set {
412+
name = "serviceAccount.create"
413+
value = "false"
414+
}
415+
416+
set {
417+
name = "cloudWatchLogs.region"
418+
value = var.region
419+
}
420+
421+
set {
422+
name = "cloudWatchLogs.logGroupTemplate"
423+
value = "/aws/eks/${aws_eks_cluster.main.id}/$(kubernetes['labels']['app.kubernetes.io/name'])"
424+
}
425+
426+
set {
427+
name = "cloudWatchLogs.logRetentionDays"
428+
value = "7"
429+
}
430+
431+
set {
432+
name = "firehose.enabled"
433+
value = false
434+
}
435+
436+
set {
437+
name = "kinesis.enabled"
438+
value = false
439+
}
440+
441+
set {
442+
name = "elasticsearch.enabled"
443+
value = false
444+
}
445+
429446
values = [
430-
templatefile("./aws-fluentbit.tpl", {
431-
logGroupName = "${var.identifier}-fluentbit"
432-
region = var.region
433-
})
447+
yamlencode({})
434448
]
435449
}

0 commit comments

Comments
 (0)