Skip to content

Commit

Permalink
fixed init env var name prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzzimmer committed Apr 30, 2024
1 parent b9c0d80 commit 9cf566c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions container_definition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ locals {
name = var.service_name
readonlyRootFilesystem = true
mountPoints = []
systemControls = []
user = startswith(upper(var.operating_system_family), "WINDOWS") ? null : "0"
volumesFrom = []

Expand Down
9 changes: 5 additions & 4 deletions fluentbit.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
locals {
s3_arn_regex = "^arn:.*:s3:"

// additional init config files from S3 or files inside a custom image
// which are added to the FluentBit container as environment variables, see
// https://github.com/aws/aws-for-fluent-bit/tree/develop/use_cases/init-process-for-fluent-bit
init_config_files = [
for idx, file_or_arn in var.firelens.init_config_files : {
name = format("aws_fluent_bit_init_%s", idx)
name = format(can(regex(local.s3_arn_regex, file_or_arn)) ? "aws_fluent_bit_init_s3_%s" : "aws_fluent_bit_init_file_%s", idx)
value = file_or_arn
}
]
Expand All @@ -13,7 +15,7 @@ locals {
image_tag = length(local.init_config_files) > 0 ? "init-2.32.0.20240122" : "2.32.0"

// additional init config files ARNs from S3 to be used in an IAM policy for the task role
s3_init_file_arns = [for conf in local.init_config_files : conf.value if can(regex("^arn:.*:s3:", conf.value))]
s3_init_file_arns = [for conf in local.init_config_files : conf.value if can(regex(local.s3_arn_regex, conf.value))]
s3_init_bucket_arns = distinct([for arn in local.s3_init_file_arns : split("/", arn)[0]])

// optional FluentBit container for log aggregation
Expand All @@ -29,7 +31,6 @@ locals {
user = startswith(upper(var.operating_system_family), "WINDOWS") ? null : "0:1337"
volumesFrom = []

# https://github.com/aws-samples/amazon-ecs-firelens-examples/tree/mainline/examples/fluent-bit/health-check
healthCheck = {
retries = 3
command = [
Expand All @@ -41,7 +42,6 @@ locals {
startPeriod = 10
}


firelensConfiguration = {
type = "fluentbit"
options = { enable-ecs-log-metadata : "true" }
Expand Down Expand Up @@ -87,6 +87,7 @@ data "aws_iam_policy_document" "fluent_bit_config_access" {
actions = ["s3:GetBucketLocation"]
resources = local.s3_init_bucket_arns
}

}

resource "aws_iam_policy" "fluent_bit_config_access" {
Expand Down

0 comments on commit 9cf566c

Please sign in to comment.