Skip to content

Commit bffb9f8

Browse files
committed
Implement s3_vectors_configuration block
1 parent 35c7b37 commit bffb9f8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

internal/service/bedrockagent/knowledge_base.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
1818
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
1919
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
20+
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
2021
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
22+
"github.com/hashicorp/terraform-plugin-framework/path"
2123
"github.com/hashicorp/terraform-plugin-framework/resource"
2224
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
2325
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
@@ -496,6 +498,53 @@ func (r *knowledgeBaseResource) Schema(ctx context.Context, request resource.Sch
496498
},
497499
},
498500
},
501+
"s3_vectors_configuration": schema.ListNestedBlock{
502+
CustomType: fwtypes.NewListNestedObjectTypeOf[s3VectorsConfigurationModel](ctx),
503+
Validators: []validator.List{
504+
listvalidator.SizeAtMost(1),
505+
},
506+
PlanModifiers: []planmodifier.List{
507+
listplanmodifier.RequiresReplace(),
508+
},
509+
NestedObject: schema.NestedBlockObject{
510+
Attributes: map[string]schema.Attribute{
511+
"index_arn": schema.StringAttribute{
512+
CustomType: fwtypes.ARNType,
513+
Optional: true,
514+
PlanModifiers: []planmodifier.String{
515+
stringplanmodifier.RequiresReplace(),
516+
},
517+
Validators: []validator.String{
518+
stringvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("index_name"), path.MatchRelative().AtParent().AtName("vector_bucket_arn")),
519+
},
520+
},
521+
"index_name": schema.StringAttribute{
522+
Optional: true,
523+
PlanModifiers: []planmodifier.String{
524+
stringplanmodifier.RequiresReplace(),
525+
},
526+
Validators: []validator.String{
527+
stringvalidator.AlsoRequires(path.MatchRelative().AtParent().AtName("vector_bucket_arn")),
528+
stringvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("index_arn")),
529+
},
530+
},
531+
"vector_bucket_arn": schema.StringAttribute{
532+
CustomType: fwtypes.ARNType,
533+
Optional: true,
534+
PlanModifiers: []planmodifier.String{
535+
stringplanmodifier.RequiresReplace(),
536+
},
537+
Validators: []validator.String{
538+
stringvalidator.AlsoRequires(path.MatchRelative().AtParent().AtName("index_name")),
539+
stringvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("index_arn")),
540+
},
541+
},
542+
},
543+
Validators: []validator.Object{
544+
objectvalidator.AtLeastOneOf(path.MatchRelative().AtName("index_arn"), path.MatchRelative().AtName("index_name")),
545+
},
546+
},
547+
},
499548
},
500549
},
501550
},
@@ -840,6 +889,7 @@ type storageConfigurationModel struct {
840889
PineconeConfiguration fwtypes.ListNestedObjectValueOf[pineconeConfigurationModel] `tfsdk:"pinecone_configuration"`
841890
RDSConfiguration fwtypes.ListNestedObjectValueOf[rdsConfigurationModel] `tfsdk:"rds_configuration"`
842891
RedisEnterpriseCloudConfiguration fwtypes.ListNestedObjectValueOf[redisEnterpriseCloudConfigurationModel] `tfsdk:"redis_enterprise_cloud_configuration"`
892+
S3VectorsConfiguration fwtypes.ListNestedObjectValueOf[s3VectorsConfigurationModel] `tfsdk:"s3_vectors_configuration"`
843893
Type types.String `tfsdk:"type"`
844894
}
845895

@@ -895,3 +945,9 @@ type redisEnterpriseCloudFieldMappingModel struct {
895945
TextField types.String `tfsdk:"text_field"`
896946
VectorField types.String `tfsdk:"vector_field"`
897947
}
948+
949+
type s3VectorsConfigurationModel struct {
950+
IndexARN fwtypes.ARN `tfsdk:"index_arn"`
951+
IndexName types.String `tfsdk:"index_name"`
952+
VectorBucketARN fwtypes.ARN `tfsdk:"vector_bucket_arn"`
953+
}

0 commit comments

Comments
 (0)