-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add ability to support multiple ALBs #13
Conversation
main.tf
Outdated
@@ -81,14 +81,23 @@ resource "aws_wafv2_web_acl" "main" { | |||
# WAFv2 web acl association with ALB | |||
##### | |||
resource "aws_wafv2_web_acl_association" "main" { | |||
count = var.enabled && var.create_alb_association ? 1 : 0 | |||
count = var.enabled && var.create_alb_association && var.alb_arn != "" ? 1 : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change we are getting an error:
Error: Invalid count argument
on ../../main.tf line 84, in resource "aws_wafv2_web_acl_association" "main":
84: count = var.enabled && var.create_alb_association && var.alb_arn != "" ? 1 : 0
The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.
This is a common thing with count unfortunately. This would only work if you provide a specific string. When you reference a module it will fail. You can replicate that behaviour by running core example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be alright now, sorry for the delay
main.tf
Outdated
|
||
resource_arn = var.alb_arn | ||
web_acl_arn = aws_wafv2_web_acl.main[0].arn | ||
|
||
depends_on = [aws_wafv2_web_acl.main] | ||
} | ||
|
||
resource "aws_wafv2_web_acl_association" "alb_list" { | ||
count = var.enabled && var.create_alb_association ? length(var.alb_arn_list) : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps in this count
we won't need var.create_alb_association
and/or it should be replaced by length(var.alb_arn_list) > 0
something to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the initial issue and decided to keep create_alb_association
, hope you don't mind
44ab78f
to
096580f
Compare
096580f
to
7da6f0f
Compare
Description
The change adds the ability to add multiple ALBs to a single WAF setup.