Skip to content

Commit

Permalink
r/aws_backup_restore_testing_selection: 'protected_resource_condition…
Browse files Browse the repository at this point in the history
…s' back to a Block.
  • Loading branch information
ewbankkit committed Oct 4, 2024
1 parent da63e9f commit 35c29aa
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions internal/service/backup/restore_testing_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/backup"
awstypes "github.com/aws/aws-sdk-go-v2/service/backup/types"
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
Expand Down Expand Up @@ -89,20 +89,6 @@ func (r *restoreTestingSelectionResource) Schema(ctx context.Context, request re
setplanmodifier.UseStateForUnknown(),
},
},
"protected_resource_conditions": schema.ListAttribute{
CustomType: fwtypes.NewListNestedObjectTypeOf[protectedResourceConditionsModel](ctx),
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
Validators: []validator.List{
listvalidator.SizeAtMost(1),
},
ElementType: types.ObjectType{
AttrTypes: fwtypes.AttributeTypesMust[protectedResourceConditionsModel](ctx),
},
},
"protected_resource_type": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
Expand Down Expand Up @@ -134,6 +120,38 @@ func (r *restoreTestingSelectionResource) Schema(ctx context.Context, request re
},
},
},
Blocks: map[string]schema.Block{
"protected_resource_conditions": schema.SingleNestedBlock{
CustomType: fwtypes.NewObjectTypeOf[protectedResourceConditionsModel](ctx),
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
Attributes: map[string]schema.Attribute{
"string_equals": schema.ListAttribute{
CustomType: fwtypes.NewListNestedObjectTypeOf[keyValueModel](ctx),
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
ElementType: types.ObjectType{
AttrTypes: fwtypes.AttributeTypesMust[keyValueModel](ctx),
},
},
"string_not_equals": schema.ListAttribute{
CustomType: fwtypes.NewListNestedObjectTypeOf[keyValueModel](ctx),
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
ElementType: types.ObjectType{
AttrTypes: fwtypes.AttributeTypesMust[keyValueModel](ctx),
},
},
},
},
},
}
}

Expand Down Expand Up @@ -336,14 +354,14 @@ func findRestoreTestingSelection(ctx context.Context, conn *backup.Client, input
}

type restoreTestingSelectionResourceModel struct {
IAMRoleARN fwtypes.ARN `tfsdk:"iam_role_arn"`
ProtectedResourceARNs fwtypes.SetOfString `tfsdk:"protected_resource_arns"`
ProtectedResourceConditions fwtypes.ListNestedObjectValueOf[protectedResourceConditionsModel] `tfsdk:"protected_resource_conditions"`
ProtectedResourceType types.String `tfsdk:"protected_resource_type"`
RestoreMetadataOverrides fwtypes.MapOfString `tfsdk:"restore_metadata_overrides"`
RestoreTestingSelectionName types.String `tfsdk:"name"`
RestoreTestingPlanName types.String `tfsdk:"restore_testing_plan_name"`
ValidationWindowHours types.Int64 `tfsdk:"validation_window_hours"`
IAMRoleARN fwtypes.ARN `tfsdk:"iam_role_arn"`
ProtectedResourceARNs fwtypes.SetOfString `tfsdk:"protected_resource_arns"`
ProtectedResourceConditions fwtypes.ObjectValueOf[protectedResourceConditionsModel] `tfsdk:"protected_resource_conditions"`
ProtectedResourceType types.String `tfsdk:"protected_resource_type"`
RestoreMetadataOverrides fwtypes.MapOfString `tfsdk:"restore_metadata_overrides"`
RestoreTestingSelectionName types.String `tfsdk:"name"`
RestoreTestingPlanName types.String `tfsdk:"restore_testing_plan_name"`
ValidationWindowHours types.Int64 `tfsdk:"validation_window_hours"`
}

type protectedResourceConditionsModel struct {
Expand Down

0 comments on commit 35c29aa

Please sign in to comment.