Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/ecs_fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ No modules.
| <a name="input_dd_image_version"></a> [dd\_image\_version](#input\_dd\_image\_version) | Datadog Agent image version | `string` | `"latest"` | no |
| <a name="input_dd_is_datadog_dependency_enabled"></a> [dd\_is\_datadog\_dependency\_enabled](#input\_dd\_is\_datadog\_dependency\_enabled) | Whether the Datadog Agent container is a dependency for other containers | `bool` | `false` | no |
| <a name="input_dd_log_collection"></a> [dd\_log\_collection](#input\_dd\_log\_collection) | Configuration for Datadog Log Collection | <pre>object({<br/> enabled = optional(bool, false)<br/> fluentbit_config = optional(object({<br/> registry = optional(string, "public.ecr.aws/aws-observability/aws-for-fluent-bit")<br/> image_version = optional(string, "stable")<br/> cpu = optional(number)<br/> memory_limit_mib = optional(number)<br/> is_log_router_essential = optional(bool, false)<br/> is_log_router_dependency_enabled = optional(bool, false)<br/> environment = optional(list(object({<br/> name = string<br/> value = string<br/> })), [])<br/> log_router_health_check = optional(object({<br/> command = optional(list(string))<br/> interval = optional(number)<br/> retries = optional(number)<br/> start_period = optional(number)<br/> timeout = optional(number)<br/> }),<br/> {<br/> command = ["CMD-SHELL", "exit 0"]<br/> interval = 5<br/> retries = 3<br/> start_period = 15<br/> timeout = 5<br/> }<br/> )<br/> firelens_options = optional(object({<br/> config_file_type = optional(string)<br/> config_file_value = optional(string)<br/> }))<br/> log_driver_configuration = optional(object({<br/> host_endpoint = optional(string, "http-intake.logs.datadoghq.com")<br/> tls = optional(bool)<br/> compress = optional(string)<br/> service_name = optional(string)<br/> source_name = optional(string)<br/> message_key = optional(string)<br/> }),<br/> {<br/> host_endpoint = "http-intake.logs.datadoghq.com"<br/> }<br/> )<br/> mountPoints = optional(list(object({<br/> sourceVolume : string,<br/> containerPath : string,<br/> readOnly : bool<br/> })), [])<br/> dependsOn = optional(list(object({<br/> containerName : string,<br/> condition : string<br/> })), [])<br/> }),<br/> {<br/> fluentbit_config = {<br/> registry = "public.ecr.aws/aws-observability/aws-for-fluent-bit"<br/> image_version = "stable"<br/> log_driver_configuration = {<br/> host_endpoint = "http-intake.logs.datadoghq.com"<br/> }<br/> }<br/> }<br/> )<br/> })</pre> | <pre>{<br/> "enabled": false,<br/> "fluentbit_config": {<br/> "is_log_router_essential": false,<br/> "log_driver_configuration": {<br/> "host_endpoint": "http-intake.logs.datadoghq.com"<br/> }<br/> }<br/>}</pre> | no |
| <a name="input_dd_manage_execution_role_secret_permissions"></a> [dd\_manage\_execution\_role\_secret\_permissions](#input\_dd\_manage\_execution\_role\_secret\_permissions) | Whether to create and attach secret access permissions to the execution role. Set to false if your execution role already has the necessary secretsmanager:GetSecretValue permissions. | `bool` | `true` | no |
| <a name="input_dd_memory_limit_mib"></a> [dd\_memory\_limit\_mib](#input\_dd\_memory\_limit\_mib) | Datadog Agent container memory limit in MiB | `number` | `null` | no |
| <a name="input_dd_registry"></a> [dd\_registry](#input\_dd\_registry) | Datadog Agent image registry | `string` | `"public.ecr.aws/datadog/agent"` | no |
| <a name="input_dd_service"></a> [dd\_service](#input\_dd\_service) | The task service name. Used for tagging (UST) | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/ecs_fargate/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# in order to provide permissions to access the secret

locals {
create_dd_secret_perms = var.dd_api_key_secret != null
create_dd_secret_perms = var.dd_api_key_secret != null && var.dd_manage_execution_role_secret_permissions
edit_execution_role = var.execution_role != null && local.create_dd_secret_perms
create_execution_role = var.execution_role == null && local.create_dd_secret_perms
parsed_exec_role_name = var.execution_role == null ? null : split("/", var.execution_role.arn)[length(split("/", var.execution_role.arn)) - 1]
Expand Down
6 changes: 6 additions & 0 deletions modules/ecs_fargate/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ variable "dd_api_key_secret" {
}
}

variable "dd_manage_execution_role_secret_permissions" {
description = "Whether to create and attach secret access permissions to the execution role. Set to false if your execution role already has the necessary secretsmanager:GetSecretValue permissions."
type = bool
default = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a bool for the new parameter, have you considered to ask the user to provide the role name so it can be possible to verify that it exists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user will already be supplying the role name via the variable execution_role. If the role exists and a secret api key is provided, we don't know if has the proper permissions configured and the module currently always adds the policy to get the secret.

  • If the role doesn't actually exist (dummy or incorrect value) then I believe the AWS API will reject the task creation request.
  • If no role is provided, then AWS API will also reject the request because it knows secrets are being loaded in which requires some execution role to be configured.

}

variable "dd_registry" {
description = "Datadog Agent image registry"
type = string
Expand Down
Loading