diff --git a/README.md b/README.md index 814d985..9d0f6db 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ for example. | [app\_mesh](#input\_app\_mesh) | Configuration of optional AWS App Mesh integration using an Envoy sidecar. |
object({| `{}` | no | | [appautoscaling\_settings](#input\_appautoscaling\_settings) | Autoscaling configuration for this service. | `map(any)` | `null` | no | | [assign\_public\_ip](#input\_assign\_public\_ip) | Assign a public IP address to the ENI of this service. | `bool` | `false` | no | +| [attach\_fluentbit\_init\_policy](#input\_attach\_fluentbit\_init\_policy) | Controls if an IAM policy granting access to fluenbit init config on S3 should be attached to the default ECS task role of this service. Only relevant if `firelens.init_config_files` is not empty. | `bool` | `true` | no | | [capacity\_provider\_strategy](#input\_capacity\_provider\_strategy) | Capacity provider strategies to use for the service. Can be one or more. |
container_definition = optional(any, {})
container_name = optional(string, "envoy")
enabled = optional(bool, false)
mesh_name = optional(string, "apps")
tls = optional(object({
acm_certificate_arn = optional(string)
root_ca_arn = optional(string)
}), {})
})
list(object({| `null` | no | | [cloudwatch\_logs](#input\_cloudwatch\_logs) | CloudWatch logs configuration for the containers of this service. CloudWatch logs will be used as the default log configuration if Firelens is disabled and for the fluentbit and otel containers. |
capacity_provider = string
weight = string
base = optional(string, null)
}))
object({| `{}` | no | | [cluster\_id](#input\_cluster\_id) | The ECS cluster id that should run this service | `string` | n/a | yes | diff --git a/fluentbit.tf b/fluentbit.tf index e82d905..fe97ced 100644 --- a/fluentbit.tf +++ b/fluentbit.tf @@ -68,7 +68,7 @@ module "fluentbit_container_definition" { } data "aws_iam_policy_document" "fluent_bit_config_access" { - count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 ? 1 : 0 + count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 && var.attach_fluentbit_init_policy ? 1 : 0 // allow reading the init config files from S3 statement { @@ -86,7 +86,7 @@ data "aws_iam_policy_document" "fluent_bit_config_access" { } resource "aws_iam_policy" "fluent_bit_config_access" { - count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 ? 1 : 0 + count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 && var.attach_fluentbit_init_policy ? 1 : 0 name = "fluent-bit-config-access-${var.service_name}-${data.aws_region.current.name}" path = "/ecs/task-role/" @@ -94,7 +94,7 @@ resource "aws_iam_policy" "fluent_bit_config_access" { } resource "aws_iam_role_policy_attachment" "fluent_bit_config_access" { - count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 ? 1 : 0 + count = var.firelens.enabled && var.task_role_arn == "" && length(local.s3_init_file_arns) > 0 && var.attach_fluentbit_init_policy ? 1 : 0 role = aws_iam_role.ecs_task_role[count.index].name policy_arn = aws_iam_policy.fluent_bit_config_access[count.index].arn diff --git a/variables.tf b/variables.tf index 930ab43..0f221e4 100644 --- a/variables.tf +++ b/variables.tf @@ -50,6 +50,11 @@ variable "app_mesh" { }) } +variable "appautoscaling_settings" { + default = null + description = "Autoscaling configuration for this service." + type = map(any) +} variable "assign_public_ip" { default = false @@ -57,10 +62,10 @@ variable "assign_public_ip" { type = bool } -variable "appautoscaling_settings" { - default = null - description = "Autoscaling configuration for this service." - type = map(any) +variable "attach_fluentbit_init_policy" { + default = true + description = "Controls if an IAM policy granting access to fluenbit init config on S3 should be attached to the default ECS task role of this service. Only relevant if `firelens.init_config_files` is not empty." + type = bool } variable "capacity_provider_strategy" {
enabled = optional(bool, true)
name = optional(string, "")
retention_in_days = optional(number, 7)
})