diff --git a/docs/data-sources/sfs_resource_pool.md b/docs/data-sources/sfs_resource_pool.md
index 6d0036947..1ef1e74ed 100644
--- a/docs/data-sources/sfs_resource_pool.md
+++ b/docs/data-sources/sfs_resource_pool.md
@@ -44,4 +44,13 @@ data "stackit_sfs_resource_pool" "resourcepool" {
- `performance_class_downgradable_at` (String) Time when the performance class can be downgraded again.
- `size_gigabytes` (Number) Size of the resource pool (unit: gigabytes)
- `size_reducible_at` (String) Time when the size can be reduced again.
+- `snapshot_policy` (Attributes) Name of the snapshot policy. (see [below for nested schema](#nestedatt--snapshot_policy))
- `snapshots_are_visible` (Boolean) If set to true, snapshots are visible and accessible to users. (default: false)
+
+
+### Nested Schema for `snapshot_policy`
+
+Read-Only:
+
+- `id` (String) ID of the snapshot policy.
+- `name` (String) Name of the snapshot policy.
diff --git a/docs/resources/sfs_resource_pool.md b/docs/resources/sfs_resource_pool.md
index 572ae0f8d..2f70fae28 100644
--- a/docs/resources/sfs_resource_pool.md
+++ b/docs/resources/sfs_resource_pool.md
@@ -51,9 +51,21 @@ import {
### Optional
- `region` (String) The resource region. If not defined, the provider region is used.
+- `snapshot_policy` (Attributes) Name of the snapshot policy. (see [below for nested schema](#nestedatt--snapshot_policy))
- `snapshots_are_visible` (Boolean) If set to true, snapshots are visible and accessible to users. (default: false)
### Read-Only
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`region`,`resource_pool_id`".
- `resource_pool_id` (String) Resource pool ID
+
+
+### Nested Schema for `snapshot_policy`
+
+Optional:
+
+- `id` (String) ID of the snapshot policy.
+
+Read-Only:
+
+- `name` (String) Name of the snapshot policy.
diff --git a/stackit/internal/services/sfs/resourcepool/datasource.go b/stackit/internal/services/sfs/resourcepool/datasource.go
index ca45b86bf..646a8c6d1 100644
--- a/stackit/internal/services/sfs/resourcepool/datasource.go
+++ b/stackit/internal/services/sfs/resourcepool/datasource.go
@@ -31,18 +31,19 @@ var (
)
type dataSourceModel struct {
- Id types.String `tfsdk:"id"` // needed by TF
- ProjectId types.String `tfsdk:"project_id"`
- ResourcePoolId types.String `tfsdk:"resource_pool_id"`
- AvailabilityZone types.String `tfsdk:"availability_zone"`
- IpAcl types.List `tfsdk:"ip_acl"`
- Name types.String `tfsdk:"name"`
- PerformanceClass types.String `tfsdk:"performance_class"`
- SizeGigabytes types.Int32 `tfsdk:"size_gigabytes"`
- SizeReducibleAt types.String `tfsdk:"size_reducible_at"`
- PerformanceClassDowngradableAt types.String `tfsdk:"performance_class_downgradable_at"`
- Region types.String `tfsdk:"region"`
- SnapshotsAreVisible types.Bool `tfsdk:"snapshots_are_visible"`
+ Id types.String `tfsdk:"id"` // needed by TF
+ ProjectId types.String `tfsdk:"project_id"`
+ ResourcePoolId types.String `tfsdk:"resource_pool_id"`
+ AvailabilityZone types.String `tfsdk:"availability_zone"`
+ IpAcl types.List `tfsdk:"ip_acl"`
+ Name types.String `tfsdk:"name"`
+ PerformanceClass types.String `tfsdk:"performance_class"`
+ SizeGigabytes types.Int32 `tfsdk:"size_gigabytes"`
+ SizeReducibleAt types.String `tfsdk:"size_reducible_at"`
+ PerformanceClassDowngradableAt types.String `tfsdk:"performance_class_downgradable_at"`
+ Region types.String `tfsdk:"region"`
+ SnapshotsAreVisible types.Bool `tfsdk:"snapshots_are_visible"`
+ SnapshotPolicy *SnapshotPolicyModel `tfsdk:"snapshot_policy"`
}
type resourcePoolDataSource struct {
@@ -191,6 +192,20 @@ func (r *resourcePoolDataSource) Schema(_ context.Context, _ datasource.SchemaRe
Computed: true,
Description: "If set to true, snapshots are visible and accessible to users. (default: false)",
},
+ "snapshot_policy": schema.SingleNestedAttribute{
+ Description: `Name of the snapshot policy.`,
+ Computed: true,
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ Description: "ID of the snapshot policy.",
+ Computed: true,
+ },
+ "name": schema.StringAttribute{
+ Description: "Name of the snapshot policy.",
+ Computed: true,
+ },
+ },
+ },
"region": schema.StringAttribute{
// the region cannot be found automatically, so it has to be passed
Optional: true,
@@ -247,5 +262,12 @@ func mapDataSourceFields(ctx context.Context, region string, resourcePool *sfs.R
model.SizeReducibleAt = types.StringValue(t.Format(time.RFC3339))
}
+ if snapshotPolicy := resourcePool.SnapshotPolicy.Get(); snapshotPolicy != nil {
+ model.SnapshotPolicy = &SnapshotPolicyModel{
+ Id: types.StringPointerValue(snapshotPolicy.Id),
+ Name: types.StringPointerValue(snapshotPolicy.Name),
+ }
+ }
+
return nil
}
diff --git a/stackit/internal/services/sfs/resourcepool/datasource_test.go b/stackit/internal/services/sfs/resourcepool/datasource_test.go
index 3785dc8c3..ed5a775d2 100644
--- a/stackit/internal/services/sfs/resourcepool/datasource_test.go
+++ b/stackit/internal/services/sfs/resourcepool/datasource_test.go
@@ -74,6 +74,10 @@ func TestMapDatasourceFields(t *testing.T) {
Space: &sfs.ResourcePoolSpace{
SizeGigabytes: utils.Ptr[int32](42),
},
+ SnapshotPolicy: *sfs.NewNullableResourcePoolSnapshotPolicy(&sfs.ResourcePoolSnapshotPolicy{
+ Id: new("snapshot-id"),
+ Name: new("snapshot-name"),
+ }),
State: new("state"),
},
expected: &dataSourceModel{
@@ -92,6 +96,10 @@ func TestMapDatasourceFields(t *testing.T) {
Region: testRegion,
SizeReducibleAt: testTimePlus1h,
PerformanceClassDowngradableAt: testTime,
+ SnapshotPolicy: &SnapshotPolicyModel{
+ Id: types.StringValue("snapshot-id"),
+ Name: types.StringValue("snapshot-name"),
+ },
},
isValid: true,
},
diff --git a/stackit/internal/services/sfs/resourcepool/resource.go b/stackit/internal/services/sfs/resourcepool/resource.go
index d47ab4204..e61ea566d 100644
--- a/stackit/internal/services/sfs/resourcepool/resource.go
+++ b/stackit/internal/services/sfs/resourcepool/resource.go
@@ -9,14 +9,19 @@ import (
"strings"
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
+ "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
sfs "github.com/stackitcloud/stackit-sdk-go/services/sfs/v1api"
@@ -27,6 +32,7 @@ import (
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features"
sfsUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/sfs/utils"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
+ stringplanmodifierUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils/planmodifiers/stringplanmodifier"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
)
@@ -38,6 +44,9 @@ var (
_ resource.ResourceWithModifyPlan = &resourcePoolResource{}
)
+// defaultSnapshotPolicyId is an empty string, which removes any snapshot policy within updates
+const defaultSnapshotPolicyId = ""
+
type Model struct {
Id types.String `tfsdk:"id"` // needed by TF
ProjectId types.String `tfsdk:"project_id"`
@@ -47,10 +56,21 @@ type Model struct {
Name types.String `tfsdk:"name"`
PerformanceClass types.String `tfsdk:"performance_class"`
SizeGigabytes types.Int32 `tfsdk:"size_gigabytes"`
+ SnapshotPolicy types.Object `tfsdk:"snapshot_policy"`
Region types.String `tfsdk:"region"`
SnapshotsAreVisible types.Bool `tfsdk:"snapshots_are_visible"`
}
+type SnapshotPolicyModel struct {
+ Id types.String `tfsdk:"id"`
+ Name types.String `tfsdk:"name"`
+}
+
+var snapshotPolicyTypes = map[string]attr.Type{
+ "id": basetypes.StringType{},
+ "name": basetypes.StringType{},
+}
+
// NewResourcePoolResource is a helper function to simplify the provider implementation.
func NewResourcePoolResource() resource.Resource {
return &resourcePoolResource{}
@@ -200,6 +220,39 @@ func (r *resourcePoolResource) Schema(_ context.Context, _ resource.SchemaReques
Computed: true,
Default: booldefault.StaticBool(false),
},
+ "snapshot_policy": schema.SingleNestedAttribute{
+ Description: `Name of the snapshot policy.`,
+ Computed: true,
+ Optional: true,
+ Default: objectdefault.StaticValue(
+ types.ObjectValueMust(snapshotPolicyTypes, map[string]attr.Value{
+ "id": types.StringValue(defaultSnapshotPolicyId),
+ "name": types.StringUnknown(),
+ }),
+ ),
+ Attributes: map[string]schema.Attribute{
+ "id": schema.StringAttribute{
+ Description: "ID of the snapshot policy.",
+ Optional: true,
+ Computed: true,
+ // ID can be either an empty string or a UUID
+ Validators: []validator.String{
+ stringvalidator.Any(
+ stringvalidator.OneOf(""),
+ validate.UUID(),
+ ),
+ },
+ Default: stringdefault.StaticString(defaultSnapshotPolicyId),
+ },
+ "name": schema.StringAttribute{
+ Description: "Name of the snapshot policy.",
+ Computed: true,
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifierUtils.UseStateForUnknownIf(stringplanmodifierUtils.StringChanged, "id", "sets `UseStateForUnknown` only if `id` has not changed"),
+ },
+ },
+ },
+ },
},
}
}
@@ -221,7 +274,7 @@ func (r *resourcePoolResource) Create(ctx context.Context, req resource.CreateRe
ctx = core.InitProviderContext(ctx)
- payload, err := toCreatePayload(&model)
+ payload, err := toCreatePayload(ctx, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating resource pool", fmt.Sprintf("Cannot create payload: %v", err))
return
@@ -314,9 +367,8 @@ func (r *resourcePoolResource) Read(ctx context.Context, req resource.ReadReques
response, err := r.client.DefaultAPI.GetResourcePool(ctx, projectId, region, resourcePoolId).Execute()
if err != nil {
- var openapiError *oapierror.GenericOpenAPIError
- if errors.As(err, &openapiError) {
- if openapiError.StatusCode == http.StatusNotFound {
+ if openapiError, ok := errors.AsType[*oapierror.GenericOpenAPIError](err); ok {
+ if openapiError.StatusCode == http.StatusNotFound || openapiError.StatusCode == http.StatusGone {
resp.State.RemoveResource(ctx)
return
}
@@ -368,7 +420,7 @@ func (r *resourcePoolResource) Update(ctx context.Context, req resource.UpdateRe
return
}
- payload, err := toUpdatePayload(&model)
+ payload, err := toUpdatePayload(ctx, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Update resource pool", fmt.Sprintf("cannot create payload: %v", err))
return
@@ -520,10 +572,22 @@ func mapFields(ctx context.Context, region string, resourcePool *sfs.ResourcePoo
model.SizeGigabytes = types.Int32PointerValue(resourcePool.Space.SizeGigabytes)
}
+ model.SnapshotPolicy = types.ObjectNull(snapshotPolicyTypes)
+ if snapshotPolicy := resourcePool.SnapshotPolicy.Get(); snapshotPolicy != nil {
+ snapshotPolicyTf, diags := types.ObjectValue(snapshotPolicyTypes, map[string]attr.Value{
+ "id": types.StringPointerValue(snapshotPolicy.Id),
+ "name": types.StringPointerValue(snapshotPolicy.Name),
+ })
+ if diags.HasError() {
+ return fmt.Errorf("failed to map snapshot policy: %w", core.DiagsToError(diags))
+ }
+ model.SnapshotPolicy = snapshotPolicyTf
+ }
+
return nil
}
-func toCreatePayload(model *Model) (*sfs.CreateResourcePoolPayload, error) {
+func toCreatePayload(ctx context.Context, model *Model) (*sfs.CreateResourcePoolPayload, error) {
if model == nil {
return nil, fmt.Errorf("nil model")
}
@@ -538,6 +602,14 @@ func toCreatePayload(model *Model) (*sfs.CreateResourcePoolPayload, error) {
aclList = tmp
}
+ snapshotPolicy := &SnapshotPolicyModel{}
+ if !utils.IsUndefined(model.SnapshotPolicy) {
+ diags := model.SnapshotPolicy.As(ctx, snapshotPolicy, basetypes.ObjectAsOptions{})
+ if diags.HasError() {
+ return nil, fmt.Errorf("cannot convert snapshot policy: %w", core.DiagsToError(diags))
+ }
+ }
+
result := &sfs.CreateResourcePoolPayload{
AvailabilityZone: model.AvailabilityZone.ValueString(),
IpAcl: aclList,
@@ -545,11 +617,13 @@ func toCreatePayload(model *Model) (*sfs.CreateResourcePoolPayload, error) {
PerformanceClass: model.PerformanceClass.ValueString(),
SizeGigabytes: model.SizeGigabytes.ValueInt32(),
SnapshotsAreVisible: model.SnapshotsAreVisible.ValueBoolPointer(),
+ SnapshotPolicyId: snapshotPolicy.Id.ValueStringPointer(),
}
+
return result, nil
}
-func toUpdatePayload(model *Model) (*sfs.UpdateResourcePoolPayload, error) {
+func toUpdatePayload(ctx context.Context, model *Model) (*sfs.UpdateResourcePoolPayload, error) {
if model == nil {
return nil, fmt.Errorf("nil model")
}
@@ -564,11 +638,20 @@ func toUpdatePayload(model *Model) (*sfs.UpdateResourcePoolPayload, error) {
aclList = tmp
}
+ snapshotPolicy := &SnapshotPolicyModel{}
+ if !utils.IsUndefined(model.SnapshotPolicy) {
+ diags := model.SnapshotPolicy.As(ctx, snapshotPolicy, basetypes.ObjectAsOptions{})
+ if diags.HasError() {
+ return nil, fmt.Errorf("cannot convert snapshot policy: %w", core.DiagsToError(diags))
+ }
+ }
+
result := &sfs.UpdateResourcePoolPayload{
IpAcl: aclList,
PerformanceClass: model.PerformanceClass.ValueStringPointer(),
SizeGigabytes: *sfs.NewNullableInt32(model.SizeGigabytes.ValueInt32Pointer()),
SnapshotsAreVisible: model.SnapshotsAreVisible.ValueBoolPointer(),
+ SnapshotPolicyId: snapshotPolicy.Id.ValueStringPointer(),
}
return result, nil
}
diff --git a/stackit/internal/services/sfs/resourcepool/resource_test.go b/stackit/internal/services/sfs/resourcepool/resource_test.go
index a78a793e7..36d9e3c59 100644
--- a/stackit/internal/services/sfs/resourcepool/resource_test.go
+++ b/stackit/internal/services/sfs/resourcepool/resource_test.go
@@ -135,6 +135,10 @@ func TestToCreatePayload(t *testing.T) {
Name: types.StringValue("testname"),
PerformanceClass: types.StringValue("performance"),
SizeGigabytes: types.Int32Value(42),
+ SnapshotPolicy: types.ObjectValueMust(snapshotPolicyTypes, map[string]attr.Value{
+ "id": types.StringValue("snapshot-id"),
+ "name": types.StringNull(),
+ }),
},
&sfs.CreateResourcePoolPayload{
AvailabilityZone: testAvailabilityZone.ValueString(),
@@ -142,6 +146,7 @@ func TestToCreatePayload(t *testing.T) {
Name: "testname",
PerformanceClass: "performance",
SizeGigabytes: 42,
+ SnapshotPolicyId: new("snapshot-id"),
},
false,
},
@@ -169,7 +174,8 @@ func TestToCreatePayload(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- got, err := toCreatePayload(tt.model)
+ ctx := context.Background()
+ got, err := toCreatePayload(ctx, tt.model)
if (err != nil) != tt.wantErr {
t.Errorf("toCreatePayload() error = %v, wantErr %v", err, tt.wantErr)
return
@@ -250,7 +256,8 @@ func TestToUpdatePayload(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- got, err := toUpdatePayload(tt.model)
+ ctx := context.Background()
+ got, err := toUpdatePayload(ctx, tt.model)
if (err != nil) != tt.wantErr {
t.Errorf("toUpdatePayload() error = %v, wantErr %v", err, tt.wantErr)
return
diff --git a/stackit/internal/services/sfs/sfs_acc_test.go b/stackit/internal/services/sfs/sfs_acc_test.go
index 546df69ea..435290cbc 100644
--- a/stackit/internal/services/sfs/sfs_acc_test.go
+++ b/stackit/internal/services/sfs/sfs_acc_test.go
@@ -121,6 +121,7 @@ var testConfigResourcePoolVarsMax = config.Variables{
"performance_class": config.StringVariable("Standard"),
"size_gigabytes": config.IntegerVariable(512),
"snapshots_are_visible": config.BoolVariable(true),
+ "snapshot_policy_id": config.StringVariable("2b138c3b-2453-11f1-97cd-d039eac4b54e"),
}
var testConfigResourcePoolVarsMaxUpdated = func() config.Variables {
@@ -429,6 +430,8 @@ func TestAccResourcePoolResourceMin(t *testing.T) {
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMin["ip_acl_1"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMin["ip_acl_2"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshots_are_visible", "false"),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.id", ""),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.name", "none"),
),
},
// Data source
@@ -464,6 +467,8 @@ func TestAccResourcePoolResourceMin(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMin["ip_acl_1"])),
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMin["ip_acl_2"])),
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "snapshots_are_visible", "false"),
+ resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "snapshot_policy.id", ""),
+ resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "snapshot_policy.name", "none"),
),
},
// Import
@@ -506,6 +511,8 @@ func TestAccResourcePoolResourceMin(t *testing.T) {
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMinUpdated()["ip_acl_1"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMinUpdated()["ip_acl_2"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshots_are_visible", "false"),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.id", ""),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.name", "none"),
),
},
// Deletion is done by the framework implicitly
@@ -535,6 +542,8 @@ func TestAccResourcePoolResourceMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["ip_acl_1"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["ip_acl_2"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshots_are_visible", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["snapshots_are_visible"])),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.id", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["snapshot_policy_id"])),
+ resource.TestCheckResourceAttrSet("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.name"),
),
},
// Data source
@@ -570,6 +579,11 @@ func TestAccResourcePoolResourceMax(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["ip_acl_1"])),
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["ip_acl_2"])),
resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "snapshots_are_visible", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["snapshots_are_visible"])),
+ resource.TestCheckResourceAttr("data.stackit_sfs_resource_pool.resource_pool_ds", "snapshot_policy.id", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["snapshot_policy_id"])),
+ resource.TestCheckResourceAttrPair(
+ "data.stackit_sfs_resource_pool.resource_pool_ds", "snapshot_policy.name",
+ "stackit_sfs_resource_pool.resourcepool", "snapshot_policy.name",
+ ),
),
},
// Import
@@ -612,7 +626,8 @@ func TestAccResourcePoolResourceMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.0", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMaxUpdated()["ip_acl_1"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "ip_acl.1", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMaxUpdated()["ip_acl_2"])),
resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshots_are_visible", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMaxUpdated()["snapshots_are_visible"])),
- ),
+ resource.TestCheckResourceAttr("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.id", testutil.ConvertConfigVariable(testConfigResourcePoolVarsMax["snapshot_policy_id"])),
+ resource.TestCheckResourceAttrSet("stackit_sfs_resource_pool.resourcepool", "snapshot_policy.name")),
},
// Deletion is done by the framework implicitly
},
diff --git a/stackit/internal/services/sfs/testdata/resource-pool-max.tf b/stackit/internal/services/sfs/testdata/resource-pool-max.tf
index 157cec744..82fc0b76b 100644
--- a/stackit/internal/services/sfs/testdata/resource-pool-max.tf
+++ b/stackit/internal/services/sfs/testdata/resource-pool-max.tf
@@ -8,6 +8,7 @@ variable "size_gigabytes" {}
variable "ip_acl_1" {}
variable "ip_acl_2" {}
variable "snapshots_are_visible" {}
+variable "snapshot_policy_id" {}
resource "stackit_sfs_resource_pool" "resourcepool" {
project_id = var.project_id
@@ -21,4 +22,7 @@ resource "stackit_sfs_resource_pool" "resourcepool" {
var.ip_acl_2
]
snapshots_are_visible = var.snapshots_are_visible
+ snapshot_policy = {
+ id = var.snapshot_policy_id
+ }
}