-
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
Error removing aws_security_group_rule that has self reference rule #1985
Comments
Hey @jedi4ever thanks for this, do you have a minimal config (minus secrets) you can share that reproduces this? Otherwise I'll try to put one together, thanks! |
I've tried to reproduce with this config: provider "aws" {
region = "us-west-2"
}
resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example_2"
description = "Used in the terraform acceptance tests"
tags {
Name = "tf_sg_web"
}
}
resource "aws_security_group" "worker" {
name = "terraform_acceptance_test_example_worker"
description = "Used in the terraform acceptance tests"
tags {
Name = "tf_sg_worker"
}
}
resource "aws_security_group_rule" "ingress_1" {
type = "ingress"
protocol = "tcp"
from_port = 22
to_port = 22
cidr_blocks = ["10.0.0.0/8"]
self = true
security_group_id = "${aws_security_group.web.id}"
}
resource "aws_security_group_rule" "ingress_2" {
type = "ingress"
protocol = "tcp"
from_port = 80
to_port = 8080
cidr_blocks = ["10.0.0.0/8"]
self = true
security_group_id = "${aws_security_group.web.id}"
} I'm using the latest Terraform, 0.5.1 (released today). Can you help me figure what I'm missing in that config? |
Unsure if it's the exact same situation as the OP, but I just ran into this by renaming a security group (that had an active instance in it). In my state file, both the old security group and instance are still around; and Manually removing the old security group from the state file allowed me to work around it (it concurrently removed both resources); sketchy though. |
I've just ran into this same problem, I can bring up a new VPC complete with subnets, instances, etc. but when I try to destroy it again, terraform can't completely remove the security group which makes things explode. My offending security group rule is:
Basically an "allow all protocols between instances in the same group" rule. Looking at how my rule differs to the examples @catsby tried, perhaps it's the protocol "-1" that's the key? Let me know if my redacted config would help. |
I poked about and this is enough to trigger the bug:
This applies fine, but when destroying yields:
Hope that helps |
I'm getting into something similar by having two security groups in a VPC, one for an ELB, one for instances. They both reference each other. |
This should be fixed in #2305 , can anyone here test out and verify ? |
LGTM 👍 Built and destroyed a VPC environment without error. |
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. |
Create succeeds fine but destroy can't.
The text was updated successfully, but these errors were encountered: