-
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
associate_public_ip_address forcing new resource when instance powered off #761
Comments
Any news on this? |
Any news on this? |
I think this can be worked around by using the
I've tested this with two of my instances that were triggering on |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
FYI: This is still happening on Terraform v0.12.24 and aws provider 2.55.0. |
When an instance is stopped, terraform cannot determine the correct value of associate_public_ip_address and should leave it alone. But right now it incorrectly interprets the current state and sets the value to false. Here is some background information on how this operates: The associate setting is sent to AWS in the RunInstances API call in the InstanceNetworkInterfaceSpecification parameter. It puts this parameter on the primary network interface. So, this is really a network interface setting. After the instance starts running, terraform examines the primary network interface in the DescribeInstancesResponse, looking for an "association" parameter. If that is present it updates associate_public_ip_address to true. If it is not present, it sets it to false. But the presence of the association is an ephemeral state that disappears in a stopped state so this is not reliable. When an instance is stopped AWS does not provide the actual setting from any API call as far as I can tell. It does appear to exist somewhere inside AWS because it reassigns public ips when the instance is restarted, and it will continue to override the subnet setting for associating public ips. This fix is to not update that setting if the instance is in a stopped state. Pull request submitted. Issue #10047 is a duplicate. |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
This issue was originally opened by @AlexLast as hashicorp/terraform#14397. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
Terraform v0.9.5
Affected Resource(s)
Expected Behavior
Actual Behavior
associate_public_ip_address: "false" => "true" (forces new resource)
Steps to Reproduce
Important Factoids
We want to have our bastion instance powered off when not in use, having this new resource forced creates a new instance any time the bastion is powered off and a change is made elsewhere. Can the instance status be checked to make sure it's running before this resource is forced? Thanks!
The text was updated successfully, but these errors were encountered: