-
Notifications
You must be signed in to change notification settings - Fork 166
Description
Description
When defining an event target as an ecs_target you need to provide the configuration options as a map, these options are not being passed on as a map to the dynamic block resulting in these errors for lines 76-79 and 83:
│ Error: Invalid function argument
│
│ on .terraform/modules/alcs_cpu_load_sh_event/main.tf line 76, in resource "aws_cloudwatch_event_target" "this":
│ 76: group = lookup(ecs_target.value, "group", null)
│ ├────────────────
│ │ ecs_target.value is true
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the
│ first argument.
and for line 80
│ Error: Unsupported attribute
│
│ on .terraform/modules/alcs_cpu_load_sh_event/main.tf line 80, in resource "aws_cloudwatch_event_target" "this":
│ 80: task_definition_arn = ecs_target.value.task_definition_arn
│ ├────────────────
│ │ ecs_target.value is true
│
│ This value does not have any attributes.
╵
The data structure for the targets
map as a whole is flattened at the start of the main.tf. I suspect this also flattens the ecs_target map required for its configuratoin
Versions
- Terraform:
15.2 - Provider(s):
3.38.0 - Module:
1.1.0
Reproduction
Steps to reproduce the behavior:
module "my_event" {
source = "terraform-aws-modules/eventbridge/aws"
bus_name = "alcs_cpu_load_sh_trigger"
rules = {
my_job = {
description = "Capture PUT into S3"
event_pattern = jsonencode({
"source" : [
"aws.s3"
],
"detail-type" : [
"AWS API Call via CloudTrail"
],
"detail" : {
"eventSource" : [
"s3.amazonaws.com"
],
"eventName" : [
"PutObject"
],
"requestParameters" : {
"bucketName" : [
module.s3_bucket.bucket_id
]
}
}
})
}
}
targets = {
my_job = [
{
name = "alcs_cpu_load_sh_trigger"
arn = data.aws_ecs_cluster.scheduled_tasks.arn
ecs_target = {
task_definition_arn = module.alcs_cpu_load_sh_fargate_task.aws_ecs_task_definition_td_arn
}
}
]
}
}
This is the code that we are using to create the event and the trigger. Even with clearing the cache every run we consistently get the errors described above.
Expected behavior
I expect the target to be setup so that it is triggered upon a file being deposited in the s3 bucket
Actual behavior
Errors as described ni the summary above