Skip to content

Commit 7917e31

Browse files
Add support for Linode Interfaces (#344)
* Add support for Linode Interfaces (#337) * Add support for Linode Interfaces * Add Linode Interface example * Address comments * go mod tidy * Bump linodego * Fix * gen doc * Fix * Fix test
1 parent 5df4c2c commit 7917e31

8 files changed

Lines changed: 1186 additions & 109 deletions

File tree

.web-docs/components/builder/linode/README.md

Lines changed: 292 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ can also be supplied to override the typical auto-generated key:
7575

7676
<!-- Code generated from the comments of the Config struct in builder/linode/config.go; DO NOT EDIT MANUALLY -->
7777

78-
- `interface` ([]Interface) - Network Interfaces to add to this Linode’s Configuration Profile. Singular repeatable
78+
- `interface` ([]Interface) - Legacy Config Network Interfaces to add to this Linode’s Configuration Profile. Singular repeatable
7979
block containing a `purpose`, a `label`, and an `ipam_address` field.
8080

81+
- `linode_interface` ([]LinodeInterface) - Newer Linode Network Interfaces to add to this Linode.
82+
8183
- `authorized_keys` ([]string) - Public SSH keys need to be appended to the Linode instance.
8284

8385
- `authorized_users` ([]string) - Users whose SSH keys need to be appended to the Linode instance.
@@ -125,14 +127,223 @@ can also be supplied to override the typical auto-generated key:
125127

126128
- `image_regions` ([]string) - The regions where the outcome image will be replicated to.
127129

130+
- `interface_generation` (string) - Specifies the interface type for the Linode. The value can be either
131+
`legacy_config` or `linode`. The default value is determined by the
132+
`interfaces_for_new_linodes` setting in the account settings.
133+
128134
<!-- End of code generated from the comments of the Config struct in builder/linode/config.go; -->
129135

130136

131-
#### Interface
137+
#### Linode Interface
138+
139+
This section outlines the fields configurable for a newer Linode interface object.
140+
141+
<!-- Code generated from the comments of the LinodeInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
142+
143+
- `firewall_id` (\*int) - The enabled firewall to secure a VPC or public interface. Not allowed for VLAN interfaces.
144+
145+
- `default_route` (\*InterfaceDefaultRoute) - Indicates if the interface serves as the default route when multiple interfaces are
146+
eligible for this role.
147+
148+
- `public` (\*PublicInterface) - Public interface settings. A Linode can have only one public interface.
149+
A public interface can have both IPv4 and IPv6 configurations.
150+
151+
- `vpc` (\*VPCInterface) - VPC interface settings.
152+
153+
- `vlan` (\*VLANInterface) - VLAN interface settings.
154+
155+
<!-- End of code generated from the comments of the LinodeInterface struct in builder/linode/linode_interfaces.go; -->
156+
157+
158+
##### Linode Interface Default Route configuration object (InterfaceDefaultRoute)
159+
160+
###### Optional
161+
162+
<!-- Code generated from the comments of the InterfaceDefaultRoute struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
163+
164+
- `ipv4` (\*bool) - Whether this interface is used for the IPv4 default route.
165+
166+
- `ipv6` (\*bool) - Whether this interface is used for the IPv6 default route.
167+
168+
<!-- End of code generated from the comments of the InterfaceDefaultRoute struct in builder/linode/linode_interfaces.go; -->
169+
170+
171+
##### Public Linode Interface configuration object (PublicInterface)
172+
173+
###### Optional
174+
175+
<!-- Code generated from the comments of the PublicInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
176+
177+
- `ipv4` (\*PublicInterfaceIPv4) - IPv4 address settings for this public interface. If omitted,
178+
a public IPv4 address is automatically allocated.
179+
180+
- `ipv6` (\*PublicInterfaceIPv6) - IPv6 address settings for the public interface.
181+
182+
<!-- End of code generated from the comments of the PublicInterface struct in builder/linode/linode_interfaces.go; -->
183+
184+
185+
##### Public Linode Interface IPv4 configuration object (PublicInterfaceIPv4)
186+
187+
###### Optional
188+
189+
<!-- Code generated from the comments of the PublicInterfaceIPv4 struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
190+
191+
- `address` ([]PublicInterfaceIPv4Address) - Blocks of IPv4 addresses to assign to this interface. Setting any to auto
192+
allocates a public IPv4 address.
193+
194+
<!-- End of code generated from the comments of the PublicInterfaceIPv4 struct in builder/linode/linode_interfaces.go; -->
195+
196+
197+
##### Public Linode Interface IPv4 Address configuration object (PublicInterfaceIPv4Address)
198+
199+
###### Required
200+
201+
<!-- Code generated from the comments of the PublicInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
202+
203+
- `address` (\*string) - The interface's public IPv4 address. You can specify which public IPv4
204+
address to configure for the interface. Setting this to auto automatically
205+
allocates a public address.
206+
207+
<!-- End of code generated from the comments of the PublicInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; -->
208+
209+
210+
###### Optional
211+
212+
<!-- Code generated from the comments of the PublicInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
213+
214+
- `primary` (\*bool) - The IPv4 primary address configures the source address for routes within
215+
the Linode on the corresponding network interface.
216+
217+
- Don't set this to false if there's only one address in the addresses array.
218+
- If more than one address is provided, primary can be set to true for one address.
219+
- If only one address is present in the addresses array, this address is automatically set as the primary address.
220+
221+
<!-- End of code generated from the comments of the PublicInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; -->
222+
223+
224+
##### Public Linode Interface IPv6 configuration object (PublicInterfaceIPv6)
225+
226+
###### Optional
227+
228+
<!-- Code generated from the comments of the PublicInterfaceIPv6 struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
229+
230+
- `ranges` ([]PublicInterfaceIPv6Range) - IPv6 address ranges to assign to this interface. If omitted, no ranges are assigned.
231+
232+
<!-- End of code generated from the comments of the PublicInterfaceIPv6 struct in builder/linode/linode_interfaces.go; -->
233+
234+
235+
##### Public Linode Interface IPv6 Range configuration object (PublicInterfaceIPv6Range)
236+
237+
###### Required
238+
239+
<!-- Code generated from the comments of the PublicInterfaceIPv6Range struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
240+
241+
- `range` (string) - Your assigned IPv6 range in CIDR notation (2001:0db8::1/64) or prefix (/64).
242+
243+
- The prefix of /64 or /56 block of IPv6 addresses.
244+
- If provided in CIDR notation, the prefix must be within the assigned ranges for the Linode.
245+
246+
<!-- End of code generated from the comments of the PublicInterfaceIPv6Range struct in builder/linode/linode_interfaces.go; -->
247+
248+
249+
##### VPC Linode Interface configuration object (VPCInterface)
250+
251+
###### Required
252+
253+
<!-- Code generated from the comments of the VPCInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
254+
255+
- `subnet_id` (int) - The VPC subnet identifier for this interface. Your subnet’s VPC must be in
256+
the same data center (region) as the Linode.
257+
258+
<!-- End of code generated from the comments of the VPCInterface struct in builder/linode/linode_interfaces.go; -->
259+
260+
261+
###### Optional
262+
263+
<!-- Code generated from the comments of the VPCInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
264+
265+
- `ipv4` (\*VPCInterfaceIPv4) - Interfaces can be configured with IPv4 addresses or ranges.
266+
267+
<!-- End of code generated from the comments of the VPCInterface struct in builder/linode/linode_interfaces.go; -->
268+
269+
270+
##### VPC Linode Interface IPv4 configuration object (VPCInterfaceIPv4)
271+
272+
###### Optional
273+
274+
<!-- Code generated from the comments of the VPCInterfaceIPv4 struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
275+
276+
- `addresses` ([]VPCInterfaceIPv4Address) - IPv4 address settings for this VPC interface.
277+
278+
- `ranges` ([]VPCInterfaceIPv4Range) - VPC IPv4 ranges.
279+
280+
<!-- End of code generated from the comments of the VPCInterfaceIPv4 struct in builder/linode/linode_interfaces.go; -->
281+
282+
283+
##### VPC Linode Interface IPv4 Address configuration object (VPCInterfaceIPv4Address)
284+
285+
###### Required
132286

133-
This section outlines the fields configurable for a single interface object.
287+
<!-- Code generated from the comments of the VPCInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
134288

135-
##### Required Interface Common Attributes
289+
- `address` (\*string) - Specifies which IPv4 address to use in the VPC subnet. You can specify which
290+
VPC Ipv4 address in the subnet to configure for the interface. You can't use
291+
an IPv4 address taken from another Linode or interface, or the first two or
292+
last two addresses in the VPC subnet. When address is set to `auto`, an IP
293+
address from the subnet is automatically assigned.
294+
295+
<!-- End of code generated from the comments of the VPCInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; -->
296+
297+
298+
###### Optional
299+
300+
<!-- Code generated from the comments of the VPCInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
301+
302+
- `primary` (\*bool) - The IPv4 primary address is used to configure the source address for routes
303+
within the Linode on the corresponding network interface.
304+
305+
- `nat_1_1_address` (\*string) - The 1:1 NAT IPv4 address used to associate a public IPv4 address with the
306+
interface's VPC subnet IPv4 address.
307+
308+
<!-- End of code generated from the comments of the VPCInterfaceIPv4Address struct in builder/linode/linode_interfaces.go; -->
309+
310+
311+
##### VPC Linode Interface IPv4 Range configuration object (VPCInterfaceIPv4Range)
312+
313+
###### Required
314+
315+
<!-- Code generated from the comments of the VPCInterfaceIPv4Range struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
316+
317+
- `range` (string) - VPC IPv4 ranges.
318+
319+
<!-- End of code generated from the comments of the VPCInterfaceIPv4Range struct in builder/linode/linode_interfaces.go; -->
320+
321+
322+
##### VLAN Linode Interface configuration object (VLANInterface)
323+
324+
###### Required
325+
326+
<!-- Code generated from the comments of the VLANInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
327+
328+
- `vlan_label` (string) - The VLAN's unique label. VLAN interfaces on the same Linode must have a unique `vlan_label`.
329+
330+
<!-- End of code generated from the comments of the VLANInterface struct in builder/linode/linode_interfaces.go; -->
331+
332+
333+
###### Optional
334+
335+
<!-- Code generated from the comments of the VLANInterface struct in builder/linode/linode_interfaces.go; DO NOT EDIT MANUALLY -->
336+
337+
- `ipam_address` (\*string) - This VLAN interface's private IPv4 address in classless inter-domain routing (CIDR) notation.
338+
339+
<!-- End of code generated from the comments of the VLANInterface struct in builder/linode/linode_interfaces.go; -->
340+
341+
342+
#### Legacy Config Interface
343+
344+
This section outlines the fields configurable for a single legacy config interface object.
345+
346+
##### Required Config Interface Common Attributes
136347

137348
<!-- Code generated from the comments of the Interface struct in builder/linode/config.go; DO NOT EDIT MANUALLY -->
138349

@@ -141,7 +352,7 @@ This section outlines the fields configurable for a single interface object.
141352
<!-- End of code generated from the comments of the Interface struct in builder/linode/config.go; -->
142353

143354

144-
##### Optional Interface Common Attributes
355+
##### Optional Config Interface Common Attributes
145356

146357
<!-- Code generated from the comments of the Interface struct in builder/linode/config.go; DO NOT EDIT MANUALLY -->
147358

@@ -174,7 +385,7 @@ This section outlines the fields configurable for a single interface object.
174385
<!-- End of code generated from the comments of the VPCInterfaceAttributes struct in builder/linode/config.go; -->
175386

176387

177-
###### VPC Interface IPv4 configuration object
388+
###### VPC Config Interface IPv4 configuration object (InterfaceIPv4)
178389

179390
<!-- Code generated from the comments of the InterfaceIPv4 struct in builder/linode/config.go; DO NOT EDIT MANUALLY -->
180391

@@ -369,3 +580,78 @@ build {
369580
}
370581
}
371582
```
583+
584+
## Linode Interface Example
585+
586+
**HCL2**
587+
588+
```hcl
589+
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
590+
591+
source "linode" "example" {
592+
image = "linode/ubuntu24.04"
593+
image_description = "My Private Image"
594+
image_label = "private-image-${local.timestamp}"
595+
instance_label = "temporary-linode-${local.timestamp}"
596+
instance_type = "g6-standard-1"
597+
region = "us-mia"
598+
ssh_username = "root"
599+
interface_generation = "linode"
600+
601+
linode_interface {
602+
firewall_id = 12345
603+
public {
604+
ipv4 {
605+
address {
606+
address = "auto"
607+
primary = true
608+
}
609+
}
610+
}
611+
}
612+
}
613+
614+
build {
615+
sources = ["source.linode.example"]
616+
}
617+
```
618+
619+
**JSON**
620+
621+
```json
622+
{
623+
"source": {
624+
"linode": {
625+
"example": {
626+
"image": "linode/ubuntu24.04",
627+
"linode_token": "YOUR API TOKEN",
628+
"region": "us-mia",
629+
"instance_type": "g6-nanode-1",
630+
"instance_label": "temporary-linode-{{timestamp}}",
631+
"image_label": "private-image-{{timestamp}}",
632+
"image_description": "My Private Image",
633+
"ssh_username": "root",
634+
"interface_generation": "linode",
635+
"linode_interface": {
636+
"firewall_id": 2930969,
637+
"public": {
638+
"ipv4": {
639+
"addresses": [
640+
{
641+
"address": "auto",
642+
"primary": true
643+
}
644+
]
645+
}
646+
}
647+
}
648+
}
649+
}
650+
},
651+
"build": {
652+
"sources": [
653+
"source.linode.example"
654+
]
655+
}
656+
}
657+
```

0 commit comments

Comments
 (0)