Skip to content
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

provider/aws: DependencyViolation on aws_security_group with circular route dependencies #2996

Closed
JeanMertz opened this issue Aug 14, 2015 · 4 comments

Comments

@JeanMertz
Copy link
Contributor

I'm getting errors like this:

* aws_security_group.master: DependencyViolation: resource sg-2173f548 has a dependent object
    status code: 400, request id: []

When trying to delete through the AWS web interface, I get this notification when trying to remove:

This security group is referenced by another security group, and cannot be deleted until you change the other security group's rules.

This happens because of rules like this:

ingress {
  from_port = 5050
  to_port = 5050
  protocol = "tcp"
  security_groups = ["${aws_security_group.master_lb.id}"]
}

The problem is that there are circular dependencies which can't be resolved by removing one security group before the other, because they all have rules depending on other groups.

So instead, Terraform should first remove all rules, before removing the group itself.

@JeanMertz JeanMertz changed the title provider/aws: DependencyViolation on aws_security_group with dependencies on other aws_security_group provider/aws: DependencyViolation on aws_security_group with circular route dependencies Aug 14, 2015
@apparentlymart
Copy link
Contributor

The handling of security groups referencing other security groups is quirky in a number of ways, which is why the separate aws_security_group_rule resource was introduced. It avoids the circular dependency issues by treating the rules and the groups as separate resources.

Would it work for you to switch to using separate rule resources to represent your configuration?

Which is not to say that what you saw isn't a bug, but I'm beginning to wonder if inline rules inside security groups ought to just be deprecated altogether since they have always acted kinda funky.

@JeanMertz
Copy link
Contributor Author

@apparentlymart thanks for that. I indeed switched to using aws_security_group_rule to solve this problem.

However, unfortunately that resource has another problem where it doesn't recognise existing rules that don't have a cidr block, but instead reference an other source rule.

It seems to be related to #2584 and causes a second TF run to want to create "missing" rules, which fails due to duplication.

@catsby
Copy link
Contributor

catsby commented Nov 3, 2016

Hey Friends – security groups and security group rules have been through a lot since this issue was open, and I'm confident this issue is resolved. If you're still hitting it, please let us know!

@catsby catsby closed this as completed Nov 3, 2016
@ghost
Copy link

ghost commented Apr 20, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants