-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
aws_security_group: no way to delete egress rule #13314
Comments
Hey @lra, thanks for the issue! Thought I would add some color as to why this issue is happening. Inside the That being said, there could be a use case for adding an additional boolean parameter |
There could be many, an obvious one is to temporary quarantine the instances of a security group. Terraform is a tool and should not dictate an opinion on things like this. If AWS allows empty security groups, tf should fully support them no? |
Hey @lra, sorry for the late response to this!
Fully agreed! I'm aiming to get to this by tomorrow, and should have a fix in place for you soon. However, for clarification on:
Terraform definitely supports empty security groups! However, the issue stems from the face that both |
Sure
Why don't you threat I guess I don't know all the ins and outs, don't bother ;) |
@grubernaut this is not really a fully-baked idea, so I'm sure there are some implications of this that would be worth sussing out, but I wonder if we could have this resource leave a note for itself in a boolean computed attribute for whether it thinks it is managing the rules for a particular security group. Assuming we had this new boolean attribute
By maintaining this state in a special flag, we can then recognize the difference between "no rules and there never have been" and "no rules but there was before". I think getting this done would require a state migration to populate a reasonable initial value for this new attribute, but otherwise it seems on the surface like it should work... |
My pull request #14332 would fix this. If an |
@apparentlymart You're fairly close to the "proper" and "best" solution that @catsby and I have come up with through internal discussions. Also, thanks for chiming in here, always helps to have second opinions on these things 😺 The initial (intentionally basic) idea above, was to use the boolean The reason In order to fully be able to manage all security group rules, we would need to be able to iterate through the entire state of all the I'm imagining this new boolean attribute to be something along the lines of @deftflux's solution, however, does help solve the issue for users who have multiple remote statefiles, as it forces the user to contain all of their security group rules in a single resource. However, this doesn't solve the issue for users who still wish to create a single security group in one statefile, and separate rules in multiple different statefiles. @lra I'm not 100% sure what you mean by your question, I apologize, but hopefully it was answered above. |
Sorry to drop a link without offering any feedback; I just wanted to get some related issues related quickly. Do you mean defining rules for the same security group in different modules that are deployed separately (with different .tfstate files)? Not that we should be opinionated in our tooling, but that would be a nightmare to maintain. Plus with the way AWS handles security group rules, I'm afraid But if what you really mean is defining rules for the same security group in different .tf configuration files within the same module, just for code organization purposes, one possible solution that comes to mind would be to do something like C# "partial" classes. Basically, a resource could be declared "partial" (or something to that effect) such that it can be re-declared in other files, and Terraform would combine all the arguments together into one resource. As far as resources knowing about each other, that would be a major paradigm shift in Terraform. Currently, resources are the main boundary. Modules are another higher-level boundary. We need to be able to see and control the ins and outs of those predictably. It might make more sense to introduce a new kind of section that would be associated with a resource where the resource could know about all of them. Then again, we basically already have that: arguments. We may just need more flexibility over how we define those arguments. (e.g. #14037) As far as I am concerned, though, it makes the most sense to put all the security group rules for a particular group in one place. I work for a large company, and InfoSec has to review all of our security group changes. We are trying to implement a process where InfoSec can simply review a pull request of the Terraform configuration. The configuration has to appear very straight-forward for that to be practical. We can't have rules for the same group sprawled out all over the place. |
I've found a workaround; set |
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. |
Terraform Version
Terraform v0.9.2
Affected Resource(s)
aws_security_group
Terraform Configuration Files
Expected Behavior
When commenting out the egress rule, I except terraform to delete the egress rule on apply
Actual Behavior
When I comment out the egress rule, terraform applies no change.
Steps to Reproduce
terraform apply
terraform apply
Workaround
I can taint the security group and apply.
The text was updated successfully, but these errors were encountered: