-
Notifications
You must be signed in to change notification settings - Fork 2
/
fluent-bit.tf
55 lines (43 loc) · 1.68 KB
/
fluent-bit.tf
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
resource "helm_release" "fluent_bit" {
name = "fluent-bit"
repository = "oci://${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com"
chart = "${module.generator.prefix}-chart-fluent-bit"
namespace = "logging"
set {
name = "configuration.role_arn"
value = aws_iam_role.fluent_bit.arn
}
set {
name = "opensearch.configuration.os_domain"
value = "kibana.${var.route53_domain}"
}
set {
name = "opensearch.configuration.aws_region"
value = var.region
}
}
resource "aws_iam_role" "fluent_bit" {
name = "${terraform.workspace}-fluent-bit"
description = "${terraform.workspace} fluent-bit role"
assume_role_policy = templatefile("${path.module}/templates/roles/oidc_aws_fluent_bit.pol.tpl", {
aws_account_id = data.aws_caller_identity.current.account_id
oidc = local.oidc_URL
aws_region = var.region
})
tags = merge({ "Name" = "${module.generator.prefix}-fluent-bit" }, module.generator.common_tags)
}
resource "aws_iam_policy" "fluent_bit" {
name = "${terraform.workspace}-fluent-bit"
path = "/"
description = "Fluent-bit policy that should be assosiated with AWS OpenSearch"
policy = templatefile("${path.module}/templates/policies/fluent_bit_policy.pol.tpl", {
aws_account_id = data.aws_caller_identity.current.account_id
aws_region = var.region
os_domain_name = "${module.generator.prefix_region}-logging" // it has an association with opesearch service
})
tags = module.generator.common_tags
}
resource "aws_iam_role_policy_attachment" "fluent-bit" {
role = aws_iam_role.fluent_bit.name
policy_arn = aws_iam_policy.fluent_bit.arn
}