Skip to content

Conversation

@fatmcgav
Copy link

@fatmcgav fatmcgav commented Dec 3, 2024

Description

The default behaviour of try will return a null value if present. So update the logic to use can(coalesce()) which will ignore a null value.

Motivation and Context

Using the following listeners value, I was getting the below error:

listeners = {
      + http_https_redirect_listener = {
          + port     = 80
          + protocol = "HTTP"
          + redirect = {
              + port        = "443"
              + protocol    = "HTTPS"
              + status_code = "HTTP_301"
            }
        }
      + https                        = {
          + fixed_response = {
              + content_type = "text/plain"
              + message_body = ""
              + status_code  = "404"
            }
          + forward        = null
          + port           = 443
          + protocol       = "HTTPS"
          + rules          = {}
        }
    }

Error:

│ Error: Invalid Attribute Combination
│
│ Either "default_action[1].target_group_arn" or "default_action[1].forward" must be specified when "default_action[1].type" is "forward".
│ default_action[1].type
│
│   with module.alb.module.alb.aws_lb_listener.this["https"],
│   on .terraform/modules/alb.alb/main.tf line 88, in resource "aws_lb_listener" "this":
│   88: resource "aws_lb_listener" "this" {
│

Breaking Changes

None

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

…alues

The default behaviour of `try` will return a `null` value if present.
So update the logic to use `can(coalesce())` which will ignore a `null` value.
@bryantbiggs
Copy link
Member

lets start with a reproduction of the issue first

@fatmcgav
Copy link
Author

fatmcgav commented Dec 3, 2024

@bryantbiggs I've stuck a simple reproducer here, albeit with a slightly different error being returned by Terraform.

The changes in this PR fix the issue though...

@github-actions
Copy link

github-actions bot commented Jan 3, 2025

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants