instance_pool: Add support for private instance pools#492
Open
francoismeulenberg wants to merge 6 commits into
Open
instance_pool: Add support for private instance pools#492francoismeulenberg wants to merge 6 commits into
francoismeulenberg wants to merge 6 commits into
Conversation
…vate finalized-changes-to-make-instance-pools-private
Author
|
Background information: So I have added it. |
kobajagi
reviewed
Feb 20, 2026
Comment on lines
+362
to
+386
| // Handle public IP assignment based on private and ipv6 settings | ||
| if privateInstance, ok := d.GetOk(AttrPrivate); ok { | ||
| privateInstanceBool := privateInstance.(bool) | ||
| if privateInstanceBool { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentNone | ||
| } else if enableIPv6, ok := d.GetOk(AttrIPv6); ok { | ||
| ipv6EnabledBool := enableIPv6.(bool) | ||
| if ipv6EnabledBool { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentDual | ||
| } else { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentInet4 | ||
| } | ||
| } else { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentInet4 | ||
| } | ||
| } else if enableIPv6, ok := d.GetOk(AttrIPv6); ok { | ||
| ipv6EnabledBool := enableIPv6.(bool) | ||
| if ipv6EnabledBool { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentDual | ||
| } else { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentInet4 | ||
| } | ||
| } else { | ||
| createPoolRequest.PublicIPAssignment = v3.CreateInstancePoolRequestPublicIPAssignmentInet4 | ||
| } |
Contributor
There was a problem hiding this comment.
Can you simplify this block with switch please?
Contributor
There was a problem hiding this comment.
hint: you can default to ipv4.
Comment on lines
+751
to
+772
| if pool.PublicIPAssignment == v3.PublicIPAssignmentNone { | ||
| if err := d.Set(AttrPrivate, true); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| if err := d.Set(AttrIPv6, false); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| } else if pool.PublicIPAssignment == v3.PublicIPAssignmentDual { | ||
| if err := d.Set(AttrPrivate, false); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| if err := d.Set(AttrIPv6, true); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| } else { | ||
| // inet4 or empty | ||
| if err := d.Set(AttrPrivate, false); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| if err := d.Set(AttrIPv6, false); err != nil { | ||
| return diag.FromErr(err) | ||
| } |
Contributor
There was a problem hiding this comment.
suggestion: I would prefer if you:
- use a switch here
- use only once the
d.Set(AttrPrivate,...)andd.Set(AttrIPv6, ...), it will keep the code easy to read (you can use variables in your switch case and set variable in the state ouside of the switch)
kobajagi
reviewed
Feb 20, 2026
| data "exoscale_template" "debian" { | ||
| zone = local.zone | ||
| name = "Linux Debian 12 (Bookworm) 64-bit" | ||
| name = "Linux Ubuntu 24.04 LTS 64-bit" |
Contributor
There was a problem hiding this comment.
Nitpick but resource name (2 lines above) is debian.
kobajagi
reviewed
Feb 20, 2026
| - [ netplan, apply ] | ||
| EOT | ||
|
|
||
| depends_on = [exoscale_private_network.test_private] |
Contributor
There was a problem hiding this comment.
terraform will make it depend due to reference in network_ids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
instance_pool: Add support for private instance pools (no public IP addresses)
Changes
Implementation
AttrPrivateschema attribute withForceNew: true(private pools cannot be converted to public or vice versa)private/ipv6attributes and the API'sPublicIPAssignmentfield:private = true→PublicIPAssignment = "none"(no public IP)ipv6 = true→PublicIPAssignment = "dual"(IPv4 + IPv6)PublicIPAssignment = "inet4"(IPv4 only)privateandipv6cannot both be enabled (ConflictsWith validation)Comments for This PR
On
rCreate()PublicIPAssignment logic:On
AttrPrivateschema:On
rUpdate()IPv6 handling:On
testResourcePrivate()cloud-init:Checklist
(For exoscale contributors)
Testing
testResourcePrivate()acceptance test that:PublicIPAssignment = "none"is set correctly in the APITestInstancePool/ResourcePrivateTestInstancePool/Resourceremains unchanged and passing➜ terraform-provider-exoscale git:(make-instance-pools-private) ✗ TF_ACC=1 go test -v -timeout=90m -tags=testacc ./pkg/resources/instance_pool/ === RUN TestInstancePool === RUN TestInstancePool/DataSource === RUN TestInstancePool/DataSourceList === RUN TestInstancePool/Resource === RUN TestInstancePool/ResourcePrivate --- PASS: TestInstancePool (242.19s) --- PASS: TestInstancePool/DataSource (59.27s) --- PASS: TestInstancePool/DataSourceList (38.75s) --- PASS: TestInstancePool/Resource (96.63s) --- PASS: TestInstancePool/ResourcePrivate (47.54s) PASS ok github.com/exoscale/terraform-provider-exoscale/pkg/resources/instance_pool 242.216s