-
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
Security groups attached to EC2 instance are flapping #3103
Comments
+1 |
6 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
This is an extremely dangerous bug as what is executed is not what's in the plan, and you can end up cutting off network traffic to a live instance. We can't isolate reproduction steps either. It appears that terraform is unable to pull a complete set of rules from some secgroups, and a modify operation fails. That modify operation failure appears to also infect the tainting of groups on an instance. I don't have better info than that just yet. On further investigation we have the same issue. We have six SGs, but terraform keeps flapping us from "4" => "6", and "2" => "6" and each time we do, it goes from 2 -> 4 -> 2 SGs. Each time it does not indicate it will remove existing groups! It appears the API call the provider is using sets all SGs in a single call and it fails to include the existing ones in the payload. |
Okay, we can replicate this across any of our instances by doing the following:
Applying this deletes all other security groups so only This is incredibly dangerous and should be triaged as a critical bug. |
We have experienced the same behavior as stated by @STRML and we also think this bug should be triaged as critical. |
Agreed @dpacaud we are deferring provider upgrades until this is addressed |
Happened almost the same but no so dangerous as in @STRML case. Terraform v0.11.0
Then run plan again and...
|
Hi everyone. 👋 I spent awhile looking into this and could not come up with a reproduction configuration on Terraform 0.11.2 + AWS 1.7.0 or Terraform 0.11.6 + AWS 1.14.0. I also notice the reports have dropped off since two months ago. If someone could provide a minimal reproduction configuration and/or debug logs of this in action on the latest Terraform and AWS provider versions, that would be very helpful. The main code dealing with What strikes me as odd here is this output from your plan diff:
Meanwhile in the various flat and modularized Terraform configurations I tried on both older and newer versions, it shows the old values in the plan diff and applies the additions correctly:
I wonder if that is related to the @cesc1989 if that instance is/was in a default VPC, that issue should be fixed as of version 1.9.0 of the AWS provider. |
Looking back at Terraform core commits upstream around the timeframe of these reports, this commit upstream (released in Terraform 0.11.3) seemed suspect: hashicorp/terraform@8d1e479 Tracing this back I found this issue upstream which affected only Terraform 0.11.2 and seemingly configurations with So, hopefully mystery solved. Please ping me if this needs to be reopened but Terraform core versions not equal to 0.11.2 should work fine. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
I apologize in advance that I am not able to provide reproduction steps for this bug. I have spent most of the day attempting to work out what is going on here (and, more importantly, working out how to reproduce this issue, but I have thus far come up empty handed.
I am using Terraform 0.11.2 and version 1.7.0 of the AWS provider. I have a rather large Terraform stack, but I am having issues with resources created by the following code:
In the state file, the
aws_instance
resource created by our internalinstance
module looks like this (I have runterraform refresh
to ensure the state file is up-to-date):Running
terraform plan
shows the following changes to be applied:Running
terraform apply
does seem to succeed:However, the instance now only has a single security group (
sg-232c3a45
). The pre-existing security groups (sg-7235af14
,sg-01c89e66
andsg-a8108ecf
) seem to have been removed.This also matches what is stored in the state file:
Subsequently running
terraform plan
shows the opposite changes to be applied:The text was updated successfully, but these errors were encountered: