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

[Bug] : hcloud_server firewall_ids removed only when set to empty array #998

Open
nomorepanic opened this issue Sep 13, 2024 · 2 comments
Open
Assignees
Labels
bug requires: plugin-framework The issue can be fixed after the resource has be migrated to the plugin framework.

Comments

@nomorepanic
Copy link

nomorepanic commented Sep 13, 2024

What happened?

When an hcloud_server resource has firewall_ids set, and firewall_ids is later removed no changes are made.

Oddly, when firewall_ids is set to an empty array, firewalls are detached.

Ran with hcloud v1.48.1 on tofu 1.8.1

What did you expect to happen?

Removing the firewall_ids field should detach firewalls from the server.

Please provide a minimal working example

Example:

hcloud_server "myserver" {
   ....
   firewall_ids = [myfirewall.id]
}

Plan & apply, then remove firewall_ids:

hcloud_server "myserver" {
   ....
}

applywill find no differences.

@jooola jooola self-assigned this Oct 14, 2024
@jooola
Copy link
Member

jooola commented Oct 14, 2024

I believe this behavior is somewhat expected, we only want to manage the firewalls attached to the server if they are defined.

This is because we also manage firewall attachment using the hcloud_firewall_attachement resource, and it does not work well if the server removes the firewalls when firewall_ids is not defined.

We could check the previous state to detect that the attribute has been removed, but this might only be supported in the plugin framework. So we will probably tackle this once we migrated the firewall resources to the plugin framework (see #752).

I recommend only using the firewall_attachement resource (https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/firewall_attachment)

@jooola jooola added the requires: plugin-framework The issue can be fixed after the resource has be migrated to the plugin framework. label Dec 20, 2024
@mkarg
Copy link

mkarg commented Dec 20, 2024

Please support the use case described in the original descirption, as it is counter-intuitive that this will attach a firewall but not detach it in turn. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug requires: plugin-framework The issue can be fixed after the resource has be migrated to the plugin framework.
Projects
None yet
Development

No branches or pull requests

3 participants