-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Applying aws_wafv2_web_acl removes DDoS auto mitigation #22869
Comments
i also plan on using shield advanced with waf and noticed there's no tf resource to enable shield's automatic ddos mitigation sounds like this could be an aws wafv2 api backend issue rather than terraform since aws has not made this a feature in a configurable resource i.e. wafv2 acl, and there's no shield api call when you tf apply. but i second having a tf resource to abstract making these api calls maybe consider using null_resource and local-exec as a last resort. this is where i am headed in the interim. https://www.terraform.io/language/resources/provisioners/syntax#provisioners-are-a-last-resort or maybe use an external data source to create and grab the ddos rulegroup arn since aws shield aws enable-application-layer-automatic-response returns no output, you could do like
arn:aws:wafv2:us-east-1:153427709519:global/rulegroup/ShieldMitigationRuleGroup_XXXXX_2ece0f4b-a0c1-408a-9dc0-e7ff67dac624_6187a29e-02a3-417b-b17d-9845c8842748/35968a00-bdc0-4494-b653-e613f881a61e deleting the ddos mitigation rule group in the acl does not remove the association in shield. nor does shield recreate a rule group. it will still say enabled, so you have to disable-application-layer-automatic-response followed by enable-application-layer-automatic-response to make a new group. also update-application-layer-automatic-response does nothing if the group is removed from the acl. |
actually, after you apply ddos auto mitigation, what you can do is describe the web acl and get the rule group reference statement and put that into tf code. then you can make changes without it getting removed. i just verified this. as defined in https://docs.aws.amazon.com/waf/latest/developerguide/ddos-automatic-app-layer-response-rg.html i.e. here is a sample rule from aws wafv2 get-web-acl
you can see that the aws managed rule group arn in account 153427709519 is generated every time the shield auto mitigation association is made using the shield api call EnableApplicationLayerAutomaticResponse (with a suffix added to the generated rule name)
|
@justinretzolk Any timelines on fixing that bug? |
@makknife your workaround sounds valid. However, we took a different approach to this. We ended up doing a custom AWS Config rule which triggers a lambda function via SSM Document (as a remediation action) for the shield protected resources which have a certain tag. The Config rule also uses a lambda to check if the AWS resources comply with the rule. So basically:
AWS Config -> Lambda to evaluate -> AWS Config -> SSM Document -> Lambda 2 to re-enable. It's cool but given that your solution works, I would rather go with that for the sake of simplicity :D If you need the whole AWS config set up, I'll ask around if we can share with the community. Just let me know. |
Hey @szymon-lyszkowski-dragon 👋 Thank you for checking in on this. Unfortunately, I'm not able to provide an estimate on when this will be looked into due to the potential of shifting priorities (we prioritize work by count of ":+1:" reactions, as well as a few other things). A larger prioritization document is in the works, but in the meantime additional information may be found in our issue lifecycle document. |
Need :) |
Got a green light. Sharing the tf "module" we use to remediate this. shield-aws-custom-config-rule |
Thanks! |
Unfortunately I cannot use this since AWS Config is already in use for central account maintenance. Does anybody have another idea of working around this issue? |
We tried the approach of importing the generated rule, our plan looks fine, but then during apply:
|
This functionality has been released in v4.56.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. 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
We have Shield advanced enabled for a specific CloudFront resource. Moreover, we've enabled DDoS auto mitigation on it.
The problem:
This has caused us problems a couple of times now, since we sometimes forget to re-enable after applying terraform.
Terraform CLI and Terraform AWS Provider Version
Terraform v1.0.0
provider registry.terraform.io/hashicorp/aws v3.74.0
Affected Resource(s)
Terraform Configuration Files
aws_wafv2_web_acl resource
Debug Output
Panic Output
Expected Behavior
Shield Advanced auto mitigation rule to not be removed
Actual Behavior
Shield Advanced auto mitigation rule is removed
Steps to Reproduce
terraform plan
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: