Skip to content
Draft
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
1 change: 1 addition & 0 deletions docs/data-sources/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ data "stackit_network" "example" {
### Optional

- `region` (String) The resource region. If not defined, the provider region is used.
- `vpc_id` (String) The ID of the VPC the network is associated with.

### Read-Only

Expand Down
14 changes: 14 additions & 0 deletions docs/resources/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ resource "stackit_network" "example_non_routed_network" {
}
routed = false
}

resource "stackit_network" "example_vpc_network" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example-vpc-network"
ipv4_nameservers = ["1.2.3.4", "5.6.7.8"]
ipv4_gateway = "10.1.2.3"
ipv4_prefix = "10.1.2.0/24"
labels = {
"key" = "value"
}
routed = false
vpc_id = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
}
```

<!-- schema generated by tfplugindocs -->
Expand Down Expand Up @@ -71,6 +84,7 @@ resource "stackit_network" "example_non_routed_network" {
- `region` (String) The resource region. If not defined, the provider region is used.
- `routed` (Boolean) If set to `true`, the network is routed and therefore accessible from other networks.
- `routing_table_id` (String) The ID of the routing table associated with the network.
- `vpc_id` (String) The ID of the VPC the network is associated with.

### Read-Only

Expand Down
13 changes: 13 additions & 0 deletions examples/resources/stackit_network/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ resource "stackit_network" "example_non_routed_network" {
}
routed = false
}

resource "stackit_network" "example_vpc_network" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example-vpc-network"
ipv4_nameservers = ["1.2.3.4", "5.6.7.8"]
ipv4_gateway = "10.1.2.3"
ipv4_prefix = "10.1.2.0/24"
labels = {
"key" = "value"
}
routed = false
vpc_id = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
}
9 changes: 9 additions & 0 deletions stackit/internal/services/iaas/network/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type DataSourceModel struct {
Region types.String `tfsdk:"region"`
RoutingTableID types.String `tfsdk:"routing_table_id"`
DHCP types.Bool `tfsdk:"dhcp"`
VPCID types.String `tfsdk:"vpc_id"`
}

// NewNetworkDataSource is a helper function to simplify the provider implementation.
Expand Down Expand Up @@ -190,6 +191,14 @@ func (d *networkDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
Description: "Shows if DHCP is enabled for the network.",
Computed: true,
},
"vpc_id": schema.StringAttribute{
Description: "The ID of the VPC the network is associated with.",
Optional: true,
Validators: []validator.String{
validate.UUID(),
validate.NoSeparator(),
},
},
},
}
}
Expand Down
12 changes: 12 additions & 0 deletions stackit/internal/services/iaas/network/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type Model struct {
Region types.String `tfsdk:"region"`
RoutingTableID types.String `tfsdk:"routing_table_id"`
DHCP types.Bool `tfsdk:"dhcp"`
VPCID types.String `tfsdk:"vpc_id"`
}

// NewNetworkResource is a helper function to simplify the provider implementation.
Expand Down Expand Up @@ -404,6 +405,17 @@ func (r *networkResource) Schema(_ context.Context, _ resource.SchemaRequest, re
boolplanmodifier.UseStateForUnknown(),
},
},
"vpc_id": schema.StringAttribute{
Description: "The ID of the VPC the network is associated with.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
validate.UUID(),
validate.NoSeparator(),
},
},
},
}
}
Expand Down