-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Attempt to get attribute from null value" error #390
Comments
Cross posting from linked PR You should change your variables in your wrapper to make it work with the existing implementation. I would start with not using null and instead default to an empty list. |
Hi @bryantbiggs,
What are you suggesting I provide to the module to get it to work? |
this variable for does not match our variable for terraform-aws-alb/variables.tf Lines 195 to 199 in 5121d71
If you are running into an issue, I would suggest opening a separate issue with steps to reproduce and any error messages/details |
Hey @bryantbiggs So using an |
OK, so have spent a bit more time experimenting today, and with a typed object variable, I simply can't get the existing code logic to work. I assert that this is due to
The above example Gist gives the following output for the + listeners = {
+ http = {
+ fixed_response = {
+ content_type = "text/plain"
+ message_body = null
+ status_code = "404"
}
+ forward = null
+ port = 80
+ protocol = "HTTP"
+ redirect = null
+ rules = {}
}
} As you can see, Lines 152 to 160 in 46ec742
However it does trigger, and results in the following 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.aws_lb_listener.this["http"],
│ on .terraform/modules/alb/main.tf line 88, in resource "aws_lb_listener" "this":
│ 88: resource "aws_lb_listener" "this" {
│
╵ Note that it's index Lines 137 to 150 in 46ec742
I also tried setting up "default" values for the fields within the Changes to Outputs:
+ listeners = {
+ http = {
+ fixed_response = {
+ content_type = "text/plain"
+ message_body = null
+ status_code = "404"
}
+ forward = {
+ stickiness = {
+ duration = null
+ enabled = false
}
+ target_groups = []
}
+ port = 80
+ protocol = "HTTP"
+ redirect = {
+ host = "#{host}"
+ path = "#{path}"
+ port = "#{port}"
+ protocol = "#{protocol}"
+ query = "#{query}"
+ status_code = "HTTP_301"
}
+ rules = {}
}
}
╷
│ 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.aws_lb_listener.this["http"],
│ on .terraform/modules/alb/main.tf line 88, in resource "aws_lb_listener" "this":
│ 88: resource "aws_lb_listener" "this" {
│ If I switch to the changes proposed in #389 , then the plan succeeds, and the following ALB resources would be created: # module.alb.aws_lb.this[0] will be created
+ resource "aws_lb" "this" {
+ arn = (known after apply)
+ arn_suffix = (known after apply)
+ client_keep_alive = 3600
+ desync_mitigation_mode = "defensive"
+ dns_name = (known after apply)
+ drop_invalid_header_fields = true
+ enable_deletion_protection = true
+ enable_http2 = true
+ enable_tls_version_and_cipher_suite_headers = false
+ enable_waf_fail_open = false
+ enable_xff_client_port = false
+ enforce_security_group_inbound_rules_on_private_link_traffic = (known after apply)
+ id = (known after apply)
+ idle_timeout = 60
+ internal = (known after apply)
+ ip_address_type = (known after apply)
+ load_balancer_type = "application"
+ name = "alb-null-error"
+ name_prefix = (known after apply)
+ preserve_host_header = false
+ security_groups = (known after apply)
+ subnets = (known after apply)
+ tags = {
+ "terraform-aws-modules" = "alb"
}
+ tags_all = {
+ "terraform-aws-modules" = "alb"
}
+ vpc_id = (known after apply)
+ xff_header_processing_mode = "append"
+ zone_id = (known after apply)
+ timeouts {}
}
# module.alb.aws_lb_listener.this["http"] will be created
+ resource "aws_lb_listener" "this" {
+ arn = (known after apply)
+ id = (known after apply)
+ load_balancer_arn = (known after apply)
+ port = 80
+ protocol = "HTTP"
+ ssl_policy = (known after apply)
+ tags = {
+ "terraform-aws-modules" = "alb"
}
+ tags_all = {
+ "terraform-aws-modules" = "alb"
}
+ tcp_idle_timeout_seconds = (known after apply)
+ default_action {
+ order = (known after apply)
+ type = "fixed-response"
+ fixed_response {
+ content_type = "text/plain"
+ status_code = "404"
}
}
} As you can see, the correct singular Based on the above, I would ask you to reconsider your stance on the changes from #389 as I believe they are a safe and useful improvement to the current behaviour. |
Description
I am attempting to create a wrapper module around this
alb
module, and as part of this am defining alisteners
var which includes a number ofobject
definitions:However the plan is failing with:
Before you submit an issue, please perform the following first:
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
terraform init
Versions
Module version [Required]: latest
Terraform version:
1.5.7
5.79.0
Reproduction Code [Required]
https://gist.github.com/fatmcgav/82606b5ceef39b92d08398a0b08ec0a4
Steps to reproduce the behavior:
Expected behavior
ALB should be created
Actual behavior
Terraform plan failed
Terminal Output Screenshot(s)
Additional context
Changes in #389 fix the issue
The text was updated successfully, but these errors were encountered: