You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I know why this specific exception is happening. I am creating this ticket to:
Document a case that currently generates a fatal stack trace but should probably be something that can be handled more gracefully... like how TF .12 currently handles lots of other errors
to ask for a "smarter" way to conditionally create a resource.
There are a few things at play here. The crash is coming from this resource:
resource"aws_security_group_rule""filebeat_ingress_cidr_6" {
type="ingress"from_port=5044to_port=5044protocol="tcp"description="Allows IPV6 Blocks Logstash/Filebeat (TCP/5044) ingres; managed by tf"# Not all networks that this SG rule will be deployed into support IPv6. After some testing, a simple ` ipv6_cidr_blocks =[]` works. We want `ipv6_cidr_blocks` to be set to EITHER an empty list or a list of strings that the user supplies. We will trust that the strings are in correct CIDR6 format.ipv6_cidr_blocks=compact(concat([],var.filebeat_ingress_ipv6_cidrs))
security_group_id=module.logstash-host.sg_id
}
Note there is no defined ipv6_cidr_block attribute on the data resource. This is because the VPC ID that the data block is "resolving" does not have IPv6 enabled.
Debug Output
I will happily provide this if it's deemed necessary.
I was expecting a "safe" error with a terraform provided message about one the function arguments being null.
Actual Behavior
I received a stack trace.
Steps to Reproduce
Please see the above code snippets.
A variable is set to null and being passed into a module. That module is attempting to set up an AWS SG rule, but there is no immeidately apparent way to "massage" a null value into an empty list that the compact/concat functions will accept.
Additional Context
There does not appear to be anything else that's relevant.
References
None that immediately come to mind.
TL:DR: A null value is being passed into the concat() function. This results in a stack trace. I believe that this is something that can be caught/handled in a more elegant way.
The null value is being passed in because i can't figure out the expression needed for checking if a variable is null and using that check to conditionally not create a resource.
The text was updated successfully, but these errors were encountered:
Hi @karl-tpio ! Thank you for opening this issue. The panic you've reported is now fixed, terraform instead provides an error message:
Error: Invalid function argument
on main.tf line 11, in output "example":
11: value = compact(var.list)
|----------------
| var.list is null
Invalid value for "list" parameter: argument must not be null.
Here's a very silly example that illustrates using null in a conditional statement:
I doubt that example is enough to fully answer your secondary question about conditionally creating a resource. For that, I recommend you visit the community forum where there are far more people ready to help, whereas the GitHub issues here are generally monitored only by our few core maintainers.
I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
ghost
locked and limited conversation to collaborators
Sep 5, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi. I know why this specific exception is happening. I am creating this ticket to:
Document a case that currently generates a fatal stack trace but should probably be something that can be handled more gracefully... like how TF .12 currently handles lots of other errors
to ask for a "smarter" way to conditionally create a resource.
Terraform Version
Terraform Configuration Files
There are a few things at play here. The crash is coming from this resource:
The crash is coming from this line:
The
aws_security_group_rule.filebeat_ingress_cidr_6
resource is inside a module that can be configured with this variable:The
filebeat_ingress_ipv6_cidrs
variable is set like this in the module caller/consumer:Critically, here's what the
data.aws_vpc.some_vpc
resource hasNote there is no defined
ipv6_cidr_block
attribute on the data resource. This is because the VPC ID that the data block is "resolving" does not have IPv6 enabled.Debug Output
I will happily provide this if it's deemed necessary.
Crash Output
Expected Behavior
I was expecting a "safe" error with a terraform provided message about one the function arguments being
null
.Actual Behavior
I received a stack trace.
Steps to Reproduce
Please see the above code snippets.
A variable is set to
null
and being passed into a module. That module is attempting to set up an AWS SG rule, but there is no immeidately apparent way to "massage" a null value into an empty list that thecompact/concat
functions will accept.Additional Context
There does not appear to be anything else that's relevant.
References
None that immediately come to mind.
TL:DR: A
null
value is being passed into theconcat()
function. This results in a stack trace. I believe that this is something that can be caught/handled in a more elegant way.The null value is being passed in because i can't figure out the expression needed for checking if a variable is null and using that check to conditionally not create a resource.
The text was updated successfully, but these errors were encountered: