Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/data-sources/vpc_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ In addition to all arguments above, the following attributes are exported:

* `ipv4` - The IPv4 range of this subnet in CIDR format.

* [`ipv6`](#ipv6) - A list of IPv6 ranges under this subnet.

* `linodes` - A list of Linodes added to this subnet.

* `id` - ID of the Linode

* `interfaces` - A list of networking interfaces objects.

* `id` - ID of the interface.

* `config_id` - ID of Linode Config that the interface is associated with. `null` for a Linode Interface.
* `active` - Whether the Interface is actively in use.

* [`ipv6`](#ipv6) - A list of IPv6 ranges under this subnet.
* `active` - Whether the Interface is actively in use.

* `created` - The date and time when the VPC Subnet was created.

Expand Down
9 changes: 7 additions & 2 deletions docs/data-sources/vpc_subnets.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ Each Linode VPC subnet will be stored in the `vpc_subnets` attribute and will ex

* `ipv4` - The IPv4 range of this subnet in CIDR format.

* [`ipv6`](#ipv6) - A list of IPv6 ranges under this subnet.

* `linodes` - A list of Linodes added to this subnet.

* `id` - ID of the Linode

* `interfaces` - A list of networking interfaces objects.

* `id` - ID of the interface.

* `config_id` - ID of Linode Config that the interface is associated with. `null` for a Linode Interface.
* `active` - Whether the Interface is actively in use.

* [`ipv6`](#ipv6) - A list of IPv6 ranges under this subnet.
* `active` - Whether the Interface is actively in use.

* `created` - The date and time when the VPC Subnet was created.

Expand Down
68 changes: 60 additions & 8 deletions docs/resources/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ resource "linode_interface" "vpc" {
}
```

### VPC (IPv6) Interface Example

The following example shows how to create a public VPC interface with a custom IPv6 configuration.

```hcl
resource "linode_interface" "vpc" {
linode_id = linode_instance.my-instance.id

vpc = {
subnet_id = 12345

ipv6 = {
is_public = true

slaac = [
{
range = "auto"
}
]

ranges = [
{
range = "auto"
}
]
}
}
}
```

### VLAN Interface Example

The following example shows how to create a VLAN interface.
Expand Down Expand Up @@ -174,25 +204,25 @@ The following arguments are supported:

* `firewall_id` - (Optional) The ID of an enabled firewall to secure a VPC or public interface. Not allowed for VLAN interfaces.

* `default_route` - (Optional) Indicates whether the interface serves as the default route when multiple interfaces are eligible for this role.
* `default_route` - (Optional) Indicates if the interface serves as the default route when multiple interfaces are eligible for this role.

* `ipv4` - (Optional) When set to true, the interface is used for the IPv4 default route.
* `ipv4` - (Optional) If set to true, the interface is used for the IPv4 default route.

* `ipv6` - (Optional) When set to true, the interface is used for the IPv6 default route.
* `ipv6` - (Optional) If set to true, the interface is used for the IPv6 default route.

* `public` - (Optional) Configuration for a Linode public interface. Exactly one of `public`, `vlan`, or `vpc` must be specified.
* `public` - (Optional) Nested attributes object for a Linode public interface. Exactly one of `public`, `vlan`, or `vpc` must be specified.

* `ipv4` - (Optional) IPv4 configuration for this interface.
* `ipv4` - (Optional) IPv4 addresses for this interface.

* `addresses` - (Optional) IPv4 addresses configured for this Linode interface. Each object in this list supports:

* `address` - (Optional) The IPv4 address. Defaults to "auto" for automatic assignment.

* `primary` - (Optional) Whether this address is the primary address for the interface.

* `ipv6` - (Optional) IPv6 configuration for this interface.
* `ipv6` - (Optional) IPv6 addresses for this interface.

* `ranges` - (Optional) IPv6 ranges in CIDR notation (2600:0db8::1/64) or prefix-only (/64). Each object in this list supports:
* `ranges` - (Optional) Configured IPv6 range in CIDR notation (2600:0db8::1/64) or prefix-only (/64). Each object in this list supports:

* `range` - (Required) The IPv6 range.

Expand Down Expand Up @@ -222,6 +252,18 @@ The following arguments are supported:

* `range` - (Required) The IPv4 range.

* `ipv6` - (Optional) IPv6 assigned through `slaac` and `ranges`. If you create a VPC interface in a subnet with IPv6 and don’t specify `slaac` or `ranges`, a SLAAC range is added automatically. **NOTE: IPv6 VPCs may not currently be available to all users.**

* `is_public` - (Optional) Indicates whether the IPv6 configuration profile interface is public. (Default `false`)

* `slaac` - (Optional) Defines IPv6 SLAAC address ranges. An address is automatically generated from the assigned /64 prefix using the Linode’s MAC address, just like on public IPv6 interfaces. Router advertisements (RA) are sent to the Linode, so standard SLAAC configuration works without any changes.

* `range` - (Optional) The IPv6 network range in CIDR notation.

* `ranges` - (Optional) Defines additional IPv6 network ranges.

* `range` - (Optional) The IPv6 network range in CIDR notation.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:
Expand Down Expand Up @@ -280,12 +322,22 @@ In addition to all arguments above, the following attributes are exported:

* `range` - The assigned IPv4 range.

* `ipv6` - IPv6 assigned through `slaac` and `ranges`. **NOTE: IPv6 VPCs may not currently be available to all users.**

* `assigned_slaac` - Assigned IPv6 SLAAC address ranges to use in the VPC subnet, calculated from `slaac` input.

* `range` - The IPv6 network range in CIDR notation.

* `assigned_ranges` - Assigned additional IPv6 ranges to use in the VPC subnet, calculated from `ranges` input.

* `range` - The IPv6 network range in CIDR notation.

## Import

Interfaces can be imported using a Linode ID followed by an Interface ID, separated by a comma, e.g.

```sh
terraform import linode_interface.example 67890,12345
terraform import linode_interface.example 12345,67890
```

## Notes
Expand Down
3 changes: 3 additions & 0 deletions linode/linodeinterface/framework_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ func (data *LinodeInterfaceModel) FlattenInterface(
vpc.IPv4 = helper.KeepOrUpdateValue(
vpc.IPv4, types.ObjectNull(vpcIPv4Attribute.GetType().(types.ObjectType).AttrTypes), pk,
)
vpc.IPv6 = helper.KeepOrUpdateValue(
vpc.IPv6, types.ObjectNull(vpcIPv6Attribute.GetType().(types.ObjectType).AttrTypes), pk,
)
vpc.SubnetID = helper.KeepOrUpdateValue(vpc.SubnetID, types.Int64Null(), pk)
return
}
Expand Down
2 changes: 1 addition & 1 deletion linode/linodeinterface/framework_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (r *Resource) ImportState(

func populateLogAttributes(ctx context.Context, model LinodeInterfaceModel) context.Context {
return helper.SetLogFieldBulk(ctx, map[string]any{
"linode_id": model.LinodeID.ValueInt64(),
"id": model.ID.ValueString(),
"linode_id": model.LinodeID.ValueInt64(),
})
}
96 changes: 96 additions & 0 deletions linode/linodeinterface/framework_resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,50 @@ var computedVPCInterfaceIPv4Range = schema.NestedAttributeObject{
},
}

var configuredVPCInterfaceIPv6SLAAC = schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"range": schema.StringAttribute{
Description: "The IPv6 network range in CIDR notation.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("auto"),
},
},
}

var computedVPCInterfaceIPv6SLAAC = schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"range": schema.StringAttribute{
Description: "The IPv6 network range in CIDR notation.",
Computed: true,
},
"address": schema.StringAttribute{
Description: "The assigned IPv6 address within the range.",
Computed: true,
},
},
}

var configuredVPCInterfaceIPv6Range = schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"range": schema.StringAttribute{
Description: "The IPv6 network range in CIDR notation.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString("auto"),
},
},
}

var computedVPCInterfaceIPv6Range = schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"range": schema.StringAttribute{
Description: "The IPv6 network range in CIDR notation.",
Computed: true,
},
},
}

var publicIPv4Attribute = schema.SingleNestedAttribute{
Description: "IPv4 addresses for this interface.",
Optional: true,
Expand Down Expand Up @@ -289,6 +333,57 @@ var vpcIPv4Attribute = schema.SingleNestedAttribute{
},
}

var vpcIPv6Attribute = schema.SingleNestedAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
Attributes: map[string]schema.Attribute{
"is_public": schema.BoolAttribute{
Description: "Indicates whether the IPv6 configuration on the Linode interface is public.",
Optional: true,
Computed: true,
},
"slaac": schema.ListNestedAttribute{
Description: "Defines IPv6 SLAAC address ranges.",
Optional: true,
NestedObject: configuredVPCInterfaceIPv6SLAAC,
Validators: []validator.List{
listvalidator.NoNullValues(),
},
},
"assigned_slaac": schema.SetNestedAttribute{
Description: "Assigned IPv6 SLAAC address ranges, calculated from `addresses` input.",
Computed: true,
NestedObject: computedVPCInterfaceIPv6SLAAC,
PlanModifiers: []planmodifier.Set{
linodesetplanmodifier.UseStateForUnknownUnlessTheseChanged(
path.MatchRoot("vpc").AtName("ipv6").AtName("slaac"),
),
},
},
"ranges": schema.ListNestedAttribute{
Description: "CIDR notation of a range (1.2.3.4/24) or prefix only (/24).",
Optional: true,
NestedObject: configuredVPCInterfaceIPv6Range,
Validators: []validator.List{
listvalidator.NoNullValues(),
},
},
"assigned_ranges": schema.SetNestedAttribute{
Description: "Assigned IPv6 ranges to use in the VPC subnet, calculated from `ranges` input.",
Computed: true,
NestedObject: computedVPCInterfaceIPv6Range,
PlanModifiers: []planmodifier.Set{
linodesetplanmodifier.UseStateForUnknownUnlessTheseChanged(
path.MatchRoot("vpc").AtName("ipv6").AtName("ranges"),
),
},
},
},
}

var vpcInterfaceSchema = schema.SingleNestedAttribute{
Description: "Linode VPC interface.",
Optional: true,
Expand All @@ -300,6 +395,7 @@ var vpcInterfaceSchema = schema.SingleNestedAttribute{
},
Attributes: map[string]schema.Attribute{
"ipv4": vpcIPv4Attribute,
"ipv6": vpcIPv6Attribute,
"subnet_id": schema.Int64Attribute{
Required: true,
Description: "The VPC subnet identifier for this interface.",
Expand Down
Loading