Skip to content

Commit 6b87932

Browse files
authored
fix(instance_server): ignore enable_ipv6 with routed_ip disabled (#2533)
* fix(instance_server): ignore enable_ipv6 with routed_ip disabled * fix lint
1 parent 2695a39 commit 6b87932

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/resources/instance_server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ attached to the server. Updates to this field will trigger a stop/start of the s
210210

211211
~> **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply.
212212

213-
- `enable_ipv6` - (Defaults to `false`) Determines if IPv6 is enabled for the server.
213+
- `enable_ipv6` - (Defaults to `false`) Determines if IPv6 is enabled for the server. Useful only with `routed_ip_enabled` as false, otherwise ipv6 is always supported.
214214

215215
- `ip_id` - (Optional) The ID of the reserved IP that is attached to the server.
216216

@@ -220,7 +220,7 @@ attached to the server. Updates to this field will trigger a stop/start of the s
220220

221221
- `enable_dynamic_ip` - (Defaults to `false`) If true a dynamic IP will be attached to the server.
222222

223-
- `routed_ip_enabled` - (Defaults to `false`) If true, the server will support routed ips only. Changing it to true will migrate the server and its IP to routed type.
223+
- `routed_ip_enabled` - (Defaults to `true`) If true, the server will support routed ips only. Changing it to true will migrate the server and its IP to routed type.
224224

225225
~> **Important:** Enabling routed ip will restart the server
226226

internal/services/instance/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ func ResourceServer() *schema.Resource {
171171
Optional: true,
172172
Default: false,
173173
Description: "Determines if IPv6 is enabled for the server",
174+
DiffSuppressFunc: func(_, _, _ string, d *schema.ResourceData) bool {
175+
// routed_ip enabled servers already support enable_ipv6. Let's ignore this argument if it is.
176+
routedIPEnabled := types.GetBool(d, "routed_ip_enabled")
177+
if routedIPEnabled == nil || routedIPEnabled.(bool) {
178+
return true
179+
}
180+
181+
return false
182+
},
174183
},
175184
"private_ip": {
176185
Type: schema.TypeString,

internal/services/instance/server_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ func TestAccServer_Ipv6(t *testing.T) {
716716
image = "ubuntu_focal"
717717
type = "DEV1-S"
718718
enable_ipv6 = true
719+
routed_ip_enabled = false
719720
}
720721
`,
721722
Check: resource.ComposeTestCheckFunc(
@@ -731,6 +732,7 @@ func TestAccServer_Ipv6(t *testing.T) {
731732
image = "ubuntu_focal"
732733
type = "DEV1-S"
733734
enable_ipv6 = false
735+
routed_ip_enabled = false
734736
}
735737
`,
736738
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)