-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
WAFv2 Web ACL interface improvement, simplification, automation #14951
Comments
Hi @dvishniakov, thanks for the issue. The WAFv2 rules are definitely more complex than v1, as a cost of more flexibility. As you noted, we follow the AWS Go SDK closely, as deviating from the API can lead to future maintenance problems. In typical use of this resource, You mentioned, however, that you wanted something more automation-friendly. One approach would be to use a combination of the Terraform JSON syntax and override files. The ACL rules could then be generated by an external tool. It may be possible to request a simplified rule API using a support ticket with AWS. I will, however, leave this issue open as a tracking issue. While we will not be investigating further at this time, we are especially open to proposals for potential solutions. |
Hi @dvishniakov 👋 -- dropping a note here that while we are still open to discussing proposals, the performance issue referenced in #2 has been addressed when using |
What was it about the AWS API that necessitated:
Instead of...
It feels like the latter could be considered a QOL feature of the terraform aws provider, even if the API behind the scenes is overly complex. I get not being able to have variables in the dynamic block property name, but like... don't make it a dynamic block? |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
Community Note
Description
I've stumbled upon significant interface change and much less dry configuration for dynamic ACLs and rules during upgrading a WAF module from using WAF Classic resources to WAFv2 resources. Below are a few examples.
I understand that the way resources are represented in the provider are mostly mimicking upstream APIs, types and objects of GO SDK because in general it makes sense. But sometimes this means more work on customers, less dry and less readable configuration, less ability of automation.
WAFv2 resources use blocks instead of attributes a lot more. While it is possible to automate and interpolate blocks in Terraform >= 0.12 (I'm not going to mention 0.11 with its pros and cons), that is:
Some of the options which I can think of, but I'm sure folks more knowledgeable in the AWS SDK, provider and Terraform codebases can suggest more and even better:
New or Affected Resource(s)
Potential Terraform Configuration
Note: all code samples are simplified, most of insignificant attributes are removed for easier reading, so copy-paste of the code will not work without modifications.
WAF Classic
Example of one rule definition which could be nicely defined in a separate file:
WAF Classic ACL:
WAFv2
Now, compare the simple WAF Classic interface with what WAFv2 requires for using externally managed rule group (no affiliation or advertisement, just a publicly available confirmation of what I've experienced): https://github.com/umotif-public/terraform-aws-waf-webaclv2/blob/master/main.tf#L10-L55
Which is only top of the iceberg. Actual rule definitions and nested statements should be defined elsewhere. Either with plain nested block statements or with a complex unreadable dynamic blocks if you want some automation.
Example of just one, top-level (not nested) dynamically-defined SQL injection rule. Dynamic XSS rule definition will look pretty similar, while other top-level rules are simpler.
Is there a name for this similarly to callback hell? dynamic block hell"?
That was a top-level statement. My brain melts when I try to think about nested statements with URL match, exclusions, mixing special IP sets there to protect admin pages or internal resources.
WAFv2 made improvement in terms of consistent resource and attribute names between global and regional WAF resources, but it would be great to keep the resource definition and automation simple as well.
References
The text was updated successfully, but these errors were encountered: