Skip to content
Open
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
2 changes: 1 addition & 1 deletion docs/data-sources/image_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ data "stackit_image_v2" "filter_distro_version" {

Optional:

- `distro` (String) Filter images by operating system distribution. For example: `ubuntu`, `ubuntu-arm64`, `debian`, `rhel`, etc.
- `distro` (String) Filter images by operating system distribution. For example: `ubuntu`, `debian`, `rhel`, etc.
- `os` (String) Filter images by operating system type, such as `linux` or `windows`.
- `secure_boot` (Boolean) Filter images with Secure Boot support. Set to `true` to match images that support Secure Boot.
- `uefi` (Boolean) Filter images based on UEFI support. Set to `true` to match images that support UEFI.
Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ data "stackit_network" "example" {
- `dhcp` (Boolean) Shows if DHCP is enabled for the network.
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`network_id`".
- `ipv4_gateway` (String) The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.
- `ipv4_nameservers` (List of String) The IPv4 nameservers of the network.
- `ipv4_nameservers` (Set of String) The IPv4 nameservers of the network.
- `ipv4_prefix` (String, Deprecated) The IPv4 prefix of the network (CIDR).
- `ipv4_prefix_length` (Number) The IPv4 prefix length of the network.
- `ipv4_prefixes` (List of String) The IPv4 prefixes of the network.
- `ipv6_gateway` (String) The IPv6 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.
- `ipv6_nameservers` (List of String) The IPv6 nameservers of the network.
- `ipv6_nameservers` (Set of String) The IPv6 nameservers of the network.
- `ipv6_prefix` (String, Deprecated) The IPv6 prefix of the network (CIDR).
- `ipv6_prefix_length` (Number) The IPv6 prefix length of the network.
- `ipv6_prefixes` (List of String) The IPv6 prefixes of the network.
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ import {

- `dhcp` (Boolean) If the network has DHCP enabled. Default value is `true`.
- `ipv4_gateway` (String) The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.
- `ipv4_nameservers` (List of String) The IPv4 nameservers of the network. If not specified on creation, it will be set with the default nameservers from the network area. If not specified on update, it will remain unchanged.
- `ipv4_nameservers` (Set of String) The IPv4 nameservers of the network. If not specified on creation, it will be set with the default nameservers from the network area. If not specified on update, it will remain unchanged.
- `ipv4_prefix` (String) The IPv4 prefix of the network (CIDR).
- `ipv4_prefix_length` (Number) The IPv4 prefix length of the network.
- `ipv6_gateway` (String) The IPv6 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.
- `ipv6_nameservers` (List of String) The IPv6 nameservers of the network.
- `ipv6_nameservers` (Set of String) The IPv6 nameservers of the network.
- `ipv6_prefix` (String) The IPv6 prefix of the network (CIDR).
- `ipv6_prefix_length` (Number) The IPv6 prefix length of the network.
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
Expand Down
488 changes: 330 additions & 158 deletions stackit/internal/services/iaas/iaas_acc_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stackit/internal/services/iaas/imagev2/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (d *imageDataV2Source) Schema(_ context.Context, _ datasource.SchemaRequest
},
"distro": schema.StringAttribute{
Optional: true,
Description: "Filter images by operating system distribution. For example: `ubuntu`, `ubuntu-arm64`, `debian`, `rhel`, etc.",
Description: "Filter images by operating system distribution. For example: `ubuntu`, `debian`, `rhel`, etc.",
},
"version": schema.StringAttribute{
Optional: true,
Expand Down
20 changes: 10 additions & 10 deletions stackit/internal/services/iaas/network/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ type DataSourceModel struct {
NetworkId types.String `tfsdk:"network_id"`
Name types.String `tfsdk:"name"`
IPv4Gateway types.String `tfsdk:"ipv4_gateway"`
IPv4Nameservers types.List `tfsdk:"ipv4_nameservers"`
IPv4Nameservers types.Set `tfsdk:"ipv4_nameservers"`
IPv4Prefix types.String `tfsdk:"ipv4_prefix"`
IPv4PrefixLength types.Int64 `tfsdk:"ipv4_prefix_length"`
IPv4Prefixes types.List `tfsdk:"ipv4_prefixes"`
IPv6Gateway types.String `tfsdk:"ipv6_gateway"`
IPv6Nameservers types.List `tfsdk:"ipv6_nameservers"`
IPv6Nameservers types.Set `tfsdk:"ipv6_nameservers"`
IPv6Prefix types.String `tfsdk:"ipv6_prefix"`
IPv6PrefixLength types.Int64 `tfsdk:"ipv6_prefix_length"`
IPv6Prefixes types.List `tfsdk:"ipv6_prefixes"`
Expand Down Expand Up @@ -118,7 +118,7 @@ func (d *networkDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
Description: "The IPv4 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.",
Computed: true,
},
"ipv4_nameservers": schema.ListAttribute{
"ipv4_nameservers": schema.SetAttribute{
Description: "The IPv4 nameservers of the network.",
Computed: true,
ElementType: types.StringType,
Expand All @@ -141,7 +141,7 @@ func (d *networkDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
Description: "The IPv6 gateway of a network. If not specified, the first IP of the network will be assigned as the gateway.",
Computed: true,
},
"ipv6_nameservers": schema.ListAttribute{
"ipv6_nameservers": schema.SetAttribute{
Description: "The IPv6 nameservers of the network.",
Computed: true,
ElementType: types.StringType,
Expand Down Expand Up @@ -267,17 +267,17 @@ func mapDataSourceFields(ctx context.Context, networkResp *iaas.Network, model *
// IPv4

if networkResp.Ipv4 == nil || networkResp.Ipv4.Nameservers == nil {
model.IPv4Nameservers = types.ListNull(types.StringType)
model.IPv4Nameservers = types.SetNull(types.StringType)
} else {
respNameservers := networkResp.Ipv4.Nameservers
modelIPv4Nameservers, err := utils.ListValueToStringSlice(model.IPv4Nameservers)
modelIPv4Nameservers, err := utils.SetValueToStringSlice(model.IPv4Nameservers)
if err != nil {
return fmt.Errorf("get current IPv4 network nameservers from model: %w", err)
}

reconciledIPv4Nameservers := utils.ReconcileStringSlices(modelIPv4Nameservers, respNameservers)

ipv4NameserversTF, diags := types.ListValueFrom(ctx, types.StringType, reconciledIPv4Nameservers)
ipv4NameserversTF, diags := types.SetValueFrom(ctx, types.StringType, reconciledIPv4Nameservers)
if diags.HasError() {
return fmt.Errorf("map IPv4 network nameservers: %w", core.DiagsToError(diags))
}
Expand Down Expand Up @@ -323,17 +323,17 @@ func mapDataSourceFields(ctx context.Context, networkResp *iaas.Network, model *
// IPv6

if networkResp.Ipv6 == nil || networkResp.Ipv6.Nameservers == nil {
model.IPv6Nameservers = types.ListNull(types.StringType)
model.IPv6Nameservers = types.SetNull(types.StringType)
} else {
respIPv6Nameservers := networkResp.Ipv6.Nameservers
modelIPv6Nameservers, errIpv6 := utils.ListValueToStringSlice(model.IPv6Nameservers)
modelIPv6Nameservers, errIpv6 := utils.SetValueToStringSlice(model.IPv6Nameservers)
if errIpv6 != nil {
return fmt.Errorf("get current IPv6 network nameservers from model: %w", errIpv6)
}

reconciledIPv6Nameservers := utils.ReconcileStringSlices(modelIPv6Nameservers, respIPv6Nameservers)

ipv6NameserversTF, ipv6Diags := types.ListValueFrom(ctx, types.StringType, reconciledIPv6Nameservers)
ipv6NameserversTF, ipv6Diags := types.SetValueFrom(ctx, types.StringType, reconciledIPv6Nameservers)
if ipv6Diags.HasError() {
return fmt.Errorf("map IPv6 network nameservers: %w", core.DiagsToError(ipv6Diags))
}
Expand Down
32 changes: 16 additions & 16 deletions stackit/internal/services/iaas/network/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func TestMapDataSourceFields(t *testing.T) {
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv4Nameservers: types.ListNull(types.StringType),
IPv4Nameservers: types.SetNull(types.StringType),
IPv4PrefixLength: types.Int64Null(),
IPv4Gateway: types.StringNull(),
IPv4Prefix: types.StringNull(),
IPv4Prefixes: types.ListNull(types.StringType),
IPv6Nameservers: types.ListNull(types.StringType),
IPv6Nameservers: types.SetNull(types.StringType),
IPv6PrefixLength: types.Int64Null(),
IPv6Gateway: types.StringNull(),
IPv6Prefix: types.StringNull(),
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestMapDataSourceFields(t *testing.T) {
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
Name: types.StringValue("name"),
IPv4Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv4Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns1"),
types.StringValue("ns2"),
}),
Expand All @@ -113,7 +113,7 @@ func TestMapDataSourceFields(t *testing.T) {
types.StringValue("192.168.42.0/24"),
types.StringValue("10.100.10.0/16"),
}),
IPv6Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv6Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns1"),
types.StringValue("ns2"),
}),
Expand All @@ -140,7 +140,7 @@ func TestMapDataSourceFields(t *testing.T) {
DataSourceModel{
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
IPv4Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv4Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns1"),
types.StringValue("ns2"),
}),
Expand All @@ -161,9 +161,9 @@ func TestMapDataSourceFields(t *testing.T) {
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv6Prefixes: types.ListNull(types.StringType),
IPv6Nameservers: types.ListNull(types.StringType),
IPv6Nameservers: types.SetNull(types.StringType),
IPv4Prefixes: types.ListNull(types.StringType),
IPv4Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv4Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns2"),
types.StringValue("ns3"),
}),
Expand All @@ -177,7 +177,7 @@ func TestMapDataSourceFields(t *testing.T) {
DataSourceModel{
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
IPv6Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv6Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns1"),
types.StringValue("ns2"),
}),
Expand All @@ -198,9 +198,9 @@ func TestMapDataSourceFields(t *testing.T) {
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv6Prefixes: types.ListNull(types.StringType),
IPv4Nameservers: types.ListNull(types.StringType),
IPv4Nameservers: types.SetNull(types.StringType),
IPv4Prefixes: types.ListNull(types.StringType),
IPv6Nameservers: types.ListValueMust(types.StringType, []attr.Value{
IPv6Nameservers: types.SetValueMust(types.StringType, []attr.Value{
types.StringValue("ns2"),
types.StringValue("ns3"),
}),
Expand Down Expand Up @@ -230,11 +230,11 @@ func TestMapDataSourceFields(t *testing.T) {
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv6Nameservers: types.ListNull(types.StringType),
IPv6Nameservers: types.SetNull(types.StringType),
IPv6PrefixLength: types.Int64Null(),
IPv6Prefixes: types.ListNull(types.StringType),
Labels: types.MapNull(types.StringType),
IPv4Nameservers: types.ListNull(types.StringType),
IPv4Nameservers: types.SetNull(types.StringType),
IPv4PrefixLength: types.Int64Value(16),
IPv4Prefix: types.StringValue("10.100.20.0/16"),
IPv4Prefixes: types.ListValueMust(types.StringType, []attr.Value{
Expand Down Expand Up @@ -270,11 +270,11 @@ func TestMapDataSourceFields(t *testing.T) {
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv4Nameservers: types.ListNull(types.StringType),
IPv4Nameservers: types.SetNull(types.StringType),
IPv4PrefixLength: types.Int64Null(),
IPv4Prefixes: types.ListNull(types.StringType),
Labels: types.MapNull(types.StringType),
IPv6Nameservers: types.ListNull(types.StringType),
IPv6Nameservers: types.SetNull(types.StringType),
IPv6PrefixLength: types.Int64Value(64),
IPv6Prefix: types.StringValue("fd12:3456:789a:3::/64"),
IPv6Prefixes: types.ListValueMust(types.StringType, []attr.Value{
Expand All @@ -300,11 +300,11 @@ func TestMapDataSourceFields(t *testing.T) {
ProjectId: types.StringValue("pid"),
NetworkId: types.StringValue("nid"),
Name: types.StringValue(""),
IPv4Nameservers: types.ListNull(types.StringType),
IPv4Nameservers: types.SetNull(types.StringType),
IPv4PrefixLength: types.Int64Null(),
IPv4Gateway: types.StringNull(),
IPv4Prefixes: types.ListNull(types.StringType),
IPv6Nameservers: types.ListNull(types.StringType),
IPv6Nameservers: types.SetNull(types.StringType),
IPv6PrefixLength: types.Int64Null(),
IPv6Gateway: types.StringNull(),
IPv6Prefixes: types.ListNull(types.StringType),
Expand Down
20 changes: 10 additions & 10 deletions stackit/internal/services/iaas/network/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ type Model struct {
NetworkId types.String `tfsdk:"network_id"`
Name types.String `tfsdk:"name"`
IPv4Gateway types.String `tfsdk:"ipv4_gateway"`
IPv4Nameservers types.List `tfsdk:"ipv4_nameservers"`
IPv4Nameservers types.Set `tfsdk:"ipv4_nameservers"`
IPv4Prefix types.String `tfsdk:"ipv4_prefix"`
IPv4PrefixLength types.Int64 `tfsdk:"ipv4_prefix_length"`
IPv4Prefixes types.List `tfsdk:"ipv4_prefixes"`
IPv6Gateway types.String `tfsdk:"ipv6_gateway"`
IPv6Nameservers types.List `tfsdk:"ipv6_nameservers"`
IPv6Nameservers types.Set `tfsdk:"ipv6_nameservers"`
IPv6Prefix types.String `tfsdk:"ipv6_prefix"`
IPv6PrefixLength types.Int64 `tfsdk:"ipv6_prefix_length"`
IPv6Prefixes types.List `tfsdk:"ipv6_prefixes"`
Expand Down Expand Up @@ -275,7 +275,7 @@ func (r *networkResource) Schema(_ context.Context, _ resource.SchemaRequest, re
validate.IP(false),
},
},
"ipv4_nameservers": schema.ListAttribute{
"ipv4_nameservers": schema.SetAttribute{
Description: "The IPv4 nameservers of the network. If not specified on creation, it will be set with the default nameservers from the network area. If not specified on update, it will remain unchanged.",
Optional: true,
Computed: true,
Expand Down Expand Up @@ -323,7 +323,7 @@ func (r *networkResource) Schema(_ context.Context, _ resource.SchemaRequest, re
validate.IP(false),
},
},
"ipv6_nameservers": schema.ListAttribute{
"ipv6_nameservers": schema.SetAttribute{
Description: "The IPv6 nameservers of the network.",
Optional: true,
Computed: true,
Expand Down Expand Up @@ -674,17 +674,17 @@ func mapFields(ctx context.Context, networkResp *iaas.Network, model *Model, reg
// IPv4

if networkResp.Ipv4 == nil || networkResp.Ipv4.Nameservers == nil {
model.IPv4Nameservers = types.ListNull(types.StringType)
model.IPv4Nameservers = types.SetNull(types.StringType)
} else {
respNameservers := networkResp.Ipv4.Nameservers
modelIPv4Nameservers, err := utils.ListValueToStringSlice(model.IPv4Nameservers)
modelIPv4Nameservers, err := utils.SetValueToStringSlice(model.IPv4Nameservers)
if err != nil {
return fmt.Errorf("get current IPv4 network nameservers from model: %w", err)
}

reconciledIPv4Nameservers := utils.ReconcileStringSlices(modelIPv4Nameservers, respNameservers)

ipv4NameserversTF, diags := types.ListValueFrom(ctx, types.StringType, reconciledIPv4Nameservers)
ipv4NameserversTF, diags := types.SetValueFrom(ctx, types.StringType, reconciledIPv4Nameservers)
if diags.HasError() {
return fmt.Errorf("map IPv4 network nameservers: %w", core.DiagsToError(diags))
}
Expand Down Expand Up @@ -732,17 +732,17 @@ func mapFields(ctx context.Context, networkResp *iaas.Network, model *Model, reg
// IPv6

if networkResp.Ipv6 == nil || networkResp.Ipv6.Nameservers == nil {
model.IPv6Nameservers = types.ListNull(types.StringType)
model.IPv6Nameservers = types.SetNull(types.StringType)
} else {
respIPv6Nameservers := networkResp.Ipv6.Nameservers
modelIPv6Nameservers, errIpv6 := utils.ListValueToStringSlice(model.IPv6Nameservers)
modelIPv6Nameservers, errIpv6 := utils.SetValueToStringSlice(model.IPv6Nameservers)
if errIpv6 != nil {
return fmt.Errorf("get current IPv6 network nameservers from model: %w", errIpv6)
}

reconciledIPv6Nameservers := utils.ReconcileStringSlices(modelIPv6Nameservers, respIPv6Nameservers)

ipv6NameserversTF, ipv6Diags := types.ListValueFrom(ctx, types.StringType, reconciledIPv6Nameservers)
ipv6NameserversTF, ipv6Diags := types.SetValueFrom(ctx, types.StringType, reconciledIPv6Nameservers)
if ipv6Diags.HasError() {
return fmt.Errorf("map IPv6 network nameservers: %w", core.DiagsToError(ipv6Diags))
}
Expand Down
Loading
Loading