Closed barnabyibis closed 1 week ago
The crux of the issue is that I don't understand the result in the error report
target_group.value is "ecs-ctnr-nz-ecomm-nz-devtest"
when the code says
type = "weighted-forward"
target_groups = {
target_group_key = container_name
In other words, I expect target_group.value to be a map(string), not just a string
I found the issue by review a sample: The target groups can be multiple so are expected to be provided as a List. This works:
actions = [{
type = "weighted-forward"
target_groups = [
{
target_group_key = container_name # Associates by name to matching target_groups resource (created next, below)
}
]
stickiness = {
enabled = strcontains(container_name, "-ecomm-") ? true : false
duration = 600
}
}]
(There is only one 'stickiness' declaration, and it is cast to a list in the module, now I look more closely)
Description
I have been using the module with success for a while now. A change in our target solution now requires sticky sessions to some target groups. When I attempt to modify from action.type == "forward" to action.type == "weighted-forward" returns an error
Error: Error in function call │ │ on ....\modules\alb\main.tf line 346, in resource "aws_lb_listener_rule" "this": │ 346: arn = try(target_group.value.arn, aws_lb_target_group.this[target_group.value.target_group_key].arn) │ ├──────────────── │ │ aws_lb_target_group.this is object with 2 attributes │ │ target_group.value is "ecs-ctnr-nz-ecomm-nz-devtest" │ │ Call to function "try" failed: no expression succeeded: │ - Unsupported attribute (at ....\modules\alb\main.tf:346,44-48) │ Can't access attributes on a primitive-typed value (string). │ - Unsupported attribute (at ....\modules\alb\main.tf:346,93-110) │ Can't access attributes on a primitive-typed value (string). │ │ At least one expression must produce a successful result.
Even though I have an aws_lb_target_group that should match, the 'try' declaration fails
Versions
Module version [Required]: 9.9.0
Terraform version:
Provider version(s):
Terraform v1.8.1 on windows_amd64
provider registry.terraform.io/hashicorp/archive v2.4.2
provider registry.terraform.io/hashicorp/aws v5.46.0
provider registry.terraform.io/hashicorp/local v2.5.1
Reproduction Code [Required]
Steps to reproduce the behavior:
No workspacesCache not cleared - I'm relying on the stored state to validate the requested ALB change
Created a standard ALB with simple target groups using the following successful code, then tried to introduce sticky sessions to the listener
Expected behavior
ALB changes by changing some target groups to use sticky sessions
Actual behavior
Error as described prevents apply
Terminal Output Screenshot(s)
Additional context