Open rschwartz-tpn opened 3 years ago
Hi @rschwartz-tpn , thank you for raising this issue. If memory serves me right, to get terraform to do the modification first to the aws_networkfirewall_firewall_policy
resource and then the rule_group deletion, we've updated our tests in the provider to use the lifecycle
create_before_destroy
attribute to ensure the rule_group
deletion doesn't hang. Lmk if this workaround is feasible and/or if it works as expected!
Ex:
resource "aws_networkfirewall_rule_group" "test" {
count = 4
capacity = 100
name = "tf-ac-test-${count.index}"
# ... other configuration ...
lifecycle {
create_before_destroy = true
}
}
Hi @anGie44 - The lifecycle
meta-argument inserted in the rule_group
has solved my problem. Is this a temporary workaround while the bug gets fixed? Thanks!
I believe we are facing the same issue. We have tried adding the lifecycle
meta-argument which doesn't appear to be helping.
We have resources: Firewall Policy stateful rule group stateless rule group
We are making a simple change to the stateless rule group name.
The rule group simply doesn't seem to acknowledge the relationship between itself and the policy.
Should I create a new issue with the configuration? Or provide it in this ticket?
I can confirm that adding the lifecycle create_before_destroy
does not help. We are still running into timeouts when trying to remove rules and are therefore currently unable to fully manage our firewall rules using Terraform.
@phill0555 Did you find a solution?
We are also facing the same issue. The lifecycle hook on it's own doesn't work for us as Terraform will attempt to create the new resource with the same name, so the request fails with A resource with the specified name already exists
. Our "workaround" is to also rename the group when we know that a change will force a recreation. But it would of course be nice if the provide could handle that situation itself 🙂
I can confirm that adding the lifecycle
create_before_destroy
does not help. We are still running into timeouts when trying to remove rules and are therefore currently unable to fully manage our firewall rules using Terraform.@phill0555 Did you find a solution?
Was quite a while ago now, but I think we saw that changing rules within the rule group didn't cause issues. So as long as you're happy with the rule group name, you can add and remove rules.
If you want to add a new rule group, (I think someone tested this at the time but can't fully remember) the solution was to:
It was a while ago now though and I'm not involved in the project that we encountered the issue in. Our first solution was to not change the rule group name.
We solved the problem by adding a hash to the rule group name based on the rule group's content. When the content changes, the name changes as well and therefore Terraform will delete the old rule and create a new one. It's an hackfix, but the provider is not able to handle it otherwise.
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.13.7
Affected Resource(s)
aws_networkfirewall_rule_group
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
make-rules module:
Debug Output
Panic Output
Expected Behavior
I would have expected the rule group to have been removed from the policy before attempting to delete it.
Actual Behavior
If you run the code with both files in local.rule_files listed, everything creates fine. If you modify the contents of any of the files, all is good. However, if you delete a file (ie: comment out "rule2" like in my pasted example above) and try to apply it, it just loops forever saying 'Still destroying...'
Steps to Reproduce
terraform apply
Terraform shows that it wants to remove the rule from the policy:
Important Factoids
We are looping over the module with a for_each to create rules. We then use a Dynamic Block to attach all the rules to the policy. Looking through the debug, it seems like the first action TF is trying is to delete the rule group. There are some references to:
So I'm not sure if there is some dependency on local.biglist to be complete before it tries to remove the rule from the policy.
References
0000