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_load_balancer_target import failed if the target is ip #961

Closed
ioah86 opened this issue Jul 24, 2024 · 1 comment · Fixed by #962 or #948
Closed

[Bug]: hcloud_load_balancer_target import failed if the target is ip #961

ioah86 opened this issue Jul 24, 2024 · 1 comment · Fixed by #962 or #948
Assignees
Labels

Comments

@ioah86
Copy link

ioah86 commented Jul 24, 2024

What happened?

Running a vanilla import with a file with contents of this type

import {
  to = hcloud_load_balancer_target.NAME123__ip__x_x_x_x
  id = "12345__ip__1.1.1.1"
}

(names and IPs are obfuscated for this example).

The command I was running was

terraform plan -generate-config-out=generated_resources.tf

Then an error occurred stating

"ip": conflicts with use_private_ip

From the documentation, I understand that if the target type is ip, then there should be no field use_private_ip. However, the field pops up in the generated terraform file, and subsequently causes the plan phase to fail.

What did you expect to happen?

I expected the import to have no problem when running

terraform plan -generate-config-out=generated_resources.tf

Please provide a minimal working example

The example above with a valid IP and resource_id is a minimum working example for this bug.

@ioah86 ioah86 added the bug label Jul 24, 2024
apricote added a commit that referenced this issue Jul 24, 2024
The fields `ip` and `use_private_ip` are marked as conflicting because
`use_private_ip` only takes effect with label selector and server id
targets.

So far we have always set `use_private_ip` to whatever the API returned.
But this causes issues with the command `terraform plan
-generate-config-out=` as it writes all attributes we set in the state
to a TF file. For an LB Target IP this now causes a conflict because
both fields are set.

This is fixed by only setting the field when the target type is not IP.

Closes #961.
@apricote
Copy link
Member

Hey @ioah86,

it looks like this comes from the loose way we interpret the Terraform provider contract. This was not an issue before, because Terraform hid those issues from users, but newer features tend to cause issues with this. We have a full refactoring on our backlog (#752) which should highlight these issues whenever we work on a resource from that list.

I have fixed this specific issue in #962, but there are probably more resources and fields with this problem in the provider, so please keep opening issues if you find anything.

@apricote apricote self-assigned this Jul 24, 2024
apricote added a commit that referenced this issue Jul 24, 2024
#962)

The fields `ip` and `use_private_ip` are marked as conflicting because
`use_private_ip` only takes effect with label selector and server id
targets.

So far we have always set `use_private_ip` to whatever the API returned.
But this causes issues with the command `terraform plan
-generate-config-out=` as it writes all attributes we set in the state
to a TF file. For an LB Target IP this now causes a conflict because
both fields are set.

This is fixed by only setting the field when the target type is not IP.

Closes #961
apricote pushed a commit that referenced this issue Jul 25, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.48.0](v1.47.0...v1.48.0)
(2024-07-25)


### Features

* add support for opentofu v1.7
([#950](#950))
([ae115a8](ae115a8))
* add support for terraform v1.9
([#949](#949))
([642ac15](642ac15))
* drop support for terraform v1.7.x
([#947](#947))
([f6372aa](f6372aa))
* **server-type:** mark included_traffic attribute as deprecated
([#963](#963))
([e8101cc](e8101cc))


### Bug Fixes

* do not continue if an api error occurred
([#958](#958))
([85a4dd0](85a4dd0))
* **load-balancer:** automatic import of target adds conflicting fields
([#962](#962))
([6c0b1c4](6c0b1c4)),
closes
[#961](#961)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants