TPT-4295: terraform: Update linode_networking_ip resource — reserved conversion & IP representation - #2327
Conversation
…& IP representation
…& IP representation
There was a problem hiding this comment.
Pull request overview
Extends the Linode IP-related Terraform resources/data sources to support the API’s updated IP representation (adding reserved + tags fields) and to support converting IPs between ephemeral and reserved via in-place updates.
Changes:
- Add
tags(and propagatereserved) across networking IP schemas/models for resources and data sources. - Update
linode_networking_ipsdata source listing logic to include unassigned reserved IPs. - Add/adjust unit + acceptance tests and update docs to reflect new fields and reserved conversion behavior.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| linode/networkingips/framework_models_unit_test.go | New unit tests for parsing IP tags/reserved into models. |
| linode/networkingips/framework_datasource.go | Merge ListIPAddresses + ListReservedIPAddresses to include unassigned reserved IPs. |
| linode/networkingips/framework_datasource_test.go | Refactor acceptance checks for ip_addresses fields (now includes tags). |
| linode/networkingips/framework_datasource_models.go | Add Tags to IPAddressModel and parse from API. |
| linode/networkingips/famework_datasource_schema.go | Expose tags on the linode_networking_ips data source schema. |
| linode/networkingipassignment/framework_resource.go | Populate computed reserved/tags for assignment entries; add helper to flatten tags. |
| linode/networkingipassignment/framework_resource_schema.go | Change assignments to nested schema and expose computed reserved/tags. |
| linode/networkingipassignment/framework_resource_model.go | Extend assignment model with reserved + tags. |
| linode/networkingip/resource_test.go | Add acceptance test for ephemeral ⇄ reserved in-place conversion + tags presence. |
| linode/networkingip/framework_resource.go | After update, re-read IP details to refresh computed fields. |
| linode/networkingip/framework_resource_schema.go | Expose computed tags on the linode_networking_ip resource schema. |
| linode/networkingip/framework_resource_model.go | Track/flatten tags from API into resource state. |
| linode/networkingip/framework_models_unit_test.go | Extend unit tests to validate tags parsing in resource/data models. |
| linode/networkingip/framework_datasource_schema.go | Expose computed tags on the linode_networking_ip data source. |
| linode/networkingip/framework_datasource_model.go | Parse API tags into the linode_networking_ip data source model. |
| linode/instancereservedipassignment/framework_schema.go | Expose computed tags on reserved IP assignment resource schema. |
| linode/instancereservedipassignment/framework_models.go | Flatten/copy tags for reserved IP assignment model. |
| linode/instancereservedipassignment/framework_models_unit_test.go | New unit tests validating tags behavior for reserved IP assignment model. |
| linode/instancenetworking/framework_models.go | Include reserved + tags in flattened instance networking IP objects. |
| linode/instancenetworking/framework_models_unit_test.go | Update unit tests for reserved/tags in instance networking IP parsing. |
| linode/instancenetworking/framework_datasource_schema.go | Extend instance networking object type with reserved + tags. |
| docs/resources/reserved_ip_assignment.md | New docs describing reserved IP assignment resource attributes including tags. |
| docs/resources/networking_ip.md | Document reserved conversion semantics + add tags attribute. |
| docs/resources/networking_ip_assignment.md | Document computed reserved + tags fields on assignment entries. |
| docs/data-sources/networking_ips.md | Document tags field on returned IPs. |
| docs/data-sources/networking_ip.md | Document tags field on networking IP data source. |
| docs/data-sources/instance_networking.md | Document reserved/tags fields on instance networking IP objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
The API spec claims this is an API filterable field. Can we double check it to see if we can toggle it to true?
…& IP representation
…& IP representation
…& IP representation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 30 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…& IP representation
…& IP representation
…& IP representation
…& IP representation - Convert reserved → ephemeral
…& IP representation - Convert reserved → ephemeral
…conversion & IP representation
…te-linode_networking_ip-resource-reserved-conversion-ip
…conversion & IP representation
…conversion & IP representation
…conversion & IP representation
…conversion & IP representation
…conversion & IP representation
…conversion & IP representation
…conversion & IP representation
…te-linode_networking_ip-resource-reserved-conversion-ip
…conversion & IP representation
|
There are still two failing tests that are triggerred by
|
…conversion & IP representation
| data "linode_networking_ips" "list" { | ||
| depends_on = [linode_networking_ip.test] | ||
| } | ||
| data "linode_networking_ips" "list" {} |
| --- | ||
| page_title: "Linode: linode_reserved_ip_assignment" | ||
| description: |- | ||
| Manages assignment of a reserved IP address to a Linode instance. | ||
| --- | ||
|
|
||
| # linode\_reserved\_ip\_assignment | ||
|
|
||
| Manages the assignment of a reserved IPv4 address to a Linode instance. | ||
|
|
||
| For more information, see the corresponding [API documentation](https://techdocs.akamai.com/linode-api/reference/post-add-linode-ip). | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```hcl | ||
| resource "linode_reserved_ip_assignment" "example" { | ||
| linode_id = linode_instance.example.id | ||
| address = linode_networking_ip.reserved.address | ||
| public = true | ||
| } | ||
| ``` | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| The following arguments are supported: | ||
|
|
||
| * `linode_id` - (Required) The ID of the Linode to assign the reserved IP to. Changing this forces creation of a new resource. | ||
|
|
||
| * `address` - (Required) The reserved IPv4 address to assign to the Linode. | ||
|
|
||
| * `public` - (Optional) Whether the IP address is public. Defaults to `true`. This must match the reserved IP's existing public/private status. Changing this forces creation of a new resource. | ||
|
|
||
| * `rdns` - (Optional) The reverse DNS assigned to this address. Configured via a separate API call after the IP is assigned. | ||
|
|
||
| * `apply_immediately` - (Optional) If true, the instance will be rebooted to update network interfaces. Defaults to `false`. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
| In addition to all arguments above, the following attributes are exported: | ||
|
|
||
| * `id` - The ID of the IPv4 address (the address itself). | ||
|
|
||
| * `gateway` - The default gateway for this address. | ||
|
|
||
| * `prefix` - The number of bits set in the subnet mask. | ||
|
|
||
| * `region` - The region this IP resides in. | ||
|
|
||
| * `subnet_mask` - The mask that separates host bits from network bits for this address. | ||
|
|
||
| * `type` - The type of IP address. | ||
|
|
||
| * `reserved` - The reservation status of the IP address. | ||
|
|
||
| * `tags` - A set of tags associated with this IP address. | ||
|
|
||
| * `assigned_entity` - The entity this IP address has been assigned to. This is null if the address is not assigned to an entity. | ||
|
|
||
| * `id` - The ID of the entity. | ||
|
|
||
| * `label` - The label of the entity. | ||
|
|
||
| * `type` - The type of the entity. | ||
|
|
||
| * `url` - The URL of the entity. | ||
|
|
||
| * `vpc_nat_1_1` - Contains information about the NAT 1:1 mapping of a public IP address to a VPC subnet. | ||
|
|
||
| * `address` - The IPv4 address that is configured as a 1:1 NAT for this VPC interface. | ||
|
|
||
| * `subnet_id` - The `id` of the VPC Subnet for this Interface. | ||
|
|
||
| * `vpc_id` - The `id` of the VPC configured for this Interface. |
| The following arguments are only available when reserving an IP address: | ||
|
|
||
| * `reserved` - (Optional) Whether this IP address should be a reserved IP. | ||
| * `reserved` - (Optional) Whether this IP address should be a reserved IP. Changing this value on an assigned IP triggers an in-place update (not replacement). Setting `reserved = true` converts an ephemeral IP to reserved. Setting `reserved = false` converts a reserved IP to ephemeral (or deletes it if unassigned). |
| // The reserved IP appears in the public list; verify 2 public IPs are present | ||
| resource.TestCheckResourceAttr(testInstanceNetworkResName, "ipv4.0.public.#", "2"), | ||
| // At least one public IP has assigned_entity populated (the reserved IP) | ||
| resource.TestCheckResourceAttrSet(testInstanceNetworkResName, "ipv4.0.public.0.assigned_entity.type"), |
…conversion & IP representation
…conversion & IP representation
| The following arguments are only available when reserving an IP address: | ||
|
|
||
| * `reserved` - (Optional) Whether this IP address should be a reserved IP. | ||
| * `reserved` - (Optional) Whether this IP address should be a reserved IP. Changing this value on an assigned IP triggers an in-place update (not replacement). Setting `reserved = true` converts an ephemeral IP to reserved. Setting `reserved = false` converts a reserved IP to ephemeral when the address is assigned. If the reserved IP is unassigned, the provider deletes the IP during the update and returns an `IP Address Deleted During Update` error; after this occurs, remove the resource from your Terraform configuration so future applies succeed. |
| * `reserved` - (Computed) Whether this IP address is a reserved IP. Populated from the IP address details after assignment. | ||
|
|
||
| * `tags` - (Computed) A set of tags associated with this IP address. Populated from the IP address details after assignment. | ||
|
|
||
| * `assigned_entity` - (Computed) The entity this IP address has been assigned to. Populated from the IP address details after assignment. |
…conversion & IP representation
ezilber-akamai
left a comment
There was a problem hiding this comment.
Implementation looks good and tests are passing locally. Nice work!
* TPT-4292: terraform: Implement linode_reserved_ip resource (#2309) * TPT-4294: terraform: Update linode_instance resource to support reserved IP assignment at creation (#2323) * TPT-4293: terraform: Implement linode_reserved_ip_types data source (#2322) * TPT-4296: terraform: Update linode_nodebalancer resource to support reserved IP assignment (#2329) * TPT-4297: terraform: Implement linode_tag Data Source with Reserved IPv4 Support (#2330) * TPT-4295: terraform: Update linode_networking_ip resource — reserved conversion & IP representation (#2327) * Update unit tests for linodego v2 * Make format --------- Co-authored-by: Michal Wojcik <32574975+mgwoj@users.noreply.github.com>
📝 Description
Extend the existing linode_networking_ip resource and related data sources to support two new API changes:
PUT /networking/ips/{address} — Add ability to convert an existing ephemeral IP to a reserved IP (and vice versa) by setting/unsetting the reserved flag.
Updated IP address representation — Add the new reserved and tags fields to all responses from /networking/ips endpoints.
✔️ How to Test