Skip to content

Commit 0035035

Browse files
committed
r/aws_bedrockagent_knowledge_base: Add storage_configuration.mongo_db_atlas_configuration argument.
1 parent b428e48 commit 0035035

File tree

4 files changed

+137
-5
lines changed

4 files changed

+137
-5
lines changed

.changelog/37220.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/aws_bedrockagent_knowledge_base: Add `storage_configuration.mongo_db_atlas_configuration` argument
3+
```

internal/service/bedrockagent/knowledge_base.go

Lines changed: 114 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,12 @@ func (r *knowledgeBaseResource) Schema(ctx context.Context, request resource.Sch
251251
},
252252
},
253253
Blocks: map[string]schema.Block{
254-
"opensearch_managed_cluster_configuration": schema.ListNestedBlock{
255-
CustomType: fwtypes.NewListNestedObjectTypeOf[openSearchManagedClusterConfigurationModel](ctx),
254+
"mongo_db_atlas_configuration": schema.ListNestedBlock{
255+
CustomType: fwtypes.NewListNestedObjectTypeOf[mongoDBAtlasConfigurationModel](ctx),
256256
Validators: []validator.List{
257257
listvalidator.SizeAtMost(1),
258258
listvalidator.ExactlyOneOf(
259+
path.MatchRelative().AtParent().AtName("mongo_db_atlas_configuration"),
259260
path.MatchRelative().AtParent().AtName("opensearch_managed_cluster_configuration"),
260261
path.MatchRelative().AtParent().AtName("opensearch_serverless_configuration"),
261262
path.MatchRelative().AtParent().AtName("pinecone_configuration"),
@@ -267,6 +268,97 @@ func (r *knowledgeBaseResource) Schema(ctx context.Context, request resource.Sch
267268
PlanModifiers: []planmodifier.List{
268269
listplanmodifier.RequiresReplace(),
269270
},
271+
NestedObject: schema.NestedBlockObject{
272+
Attributes: map[string]schema.Attribute{
273+
"collection_name": schema.StringAttribute{
274+
Required: true,
275+
PlanModifiers: []planmodifier.String{
276+
stringplanmodifier.RequiresReplace(),
277+
},
278+
},
279+
"credentials_secret_arn": schema.StringAttribute{
280+
CustomType: fwtypes.ARNType,
281+
Required: true,
282+
PlanModifiers: []planmodifier.String{
283+
stringplanmodifier.RequiresReplace(),
284+
},
285+
},
286+
"database_name": schema.StringAttribute{
287+
Required: true,
288+
PlanModifiers: []planmodifier.String{
289+
stringplanmodifier.RequiresReplace(),
290+
},
291+
},
292+
"endpoint": schema.StringAttribute{
293+
Required: true,
294+
PlanModifiers: []planmodifier.String{
295+
stringplanmodifier.RequiresReplace(),
296+
},
297+
},
298+
"endpoint_service_name": schema.StringAttribute{
299+
Optional: true,
300+
PlanModifiers: []planmodifier.String{
301+
stringplanmodifier.RequiresReplace(),
302+
},
303+
},
304+
"text_index_name": schema.StringAttribute{
305+
Optional: true,
306+
PlanModifiers: []planmodifier.String{
307+
stringplanmodifier.RequiresReplace(),
308+
},
309+
},
310+
"vector_index_name": schema.StringAttribute{
311+
Required: true,
312+
PlanModifiers: []planmodifier.String{
313+
stringplanmodifier.RequiresReplace(),
314+
},
315+
},
316+
},
317+
Blocks: map[string]schema.Block{
318+
"field_mapping": schema.ListNestedBlock{
319+
CustomType: fwtypes.NewListNestedObjectTypeOf[mongoDBAtlasFieldMappingModel](ctx),
320+
Validators: []validator.List{
321+
listvalidator.IsRequired(),
322+
listvalidator.SizeAtLeast(1),
323+
listvalidator.SizeAtMost(1),
324+
},
325+
PlanModifiers: []planmodifier.List{
326+
listplanmodifier.RequiresReplace(),
327+
},
328+
NestedObject: schema.NestedBlockObject{
329+
Attributes: map[string]schema.Attribute{
330+
"metadata_field": schema.StringAttribute{
331+
Required: true,
332+
PlanModifiers: []planmodifier.String{
333+
stringplanmodifier.RequiresReplace(),
334+
},
335+
},
336+
"text_field": schema.StringAttribute{
337+
Required: true,
338+
PlanModifiers: []planmodifier.String{
339+
stringplanmodifier.RequiresReplace(),
340+
},
341+
},
342+
"vector_field": schema.StringAttribute{
343+
Required: true,
344+
PlanModifiers: []planmodifier.String{
345+
stringplanmodifier.RequiresReplace(),
346+
},
347+
},
348+
},
349+
},
350+
},
351+
},
352+
},
353+
},
354+
"opensearch_managed_cluster_configuration": schema.ListNestedBlock{
355+
CustomType: fwtypes.NewListNestedObjectTypeOf[openSearchManagedClusterConfigurationModel](ctx),
356+
Validators: []validator.List{
357+
listvalidator.SizeAtMost(1),
358+
},
359+
PlanModifiers: []planmodifier.List{
360+
listplanmodifier.RequiresReplace(),
361+
},
270362
NestedObject: schema.NestedBlockObject{
271363
Attributes: map[string]schema.Attribute{
272364
"domain_arn": schema.StringAttribute{
@@ -1010,15 +1102,33 @@ type kendraKnowledgeBaseConfigurationModel struct {
10101102
}
10111103

10121104
type storageConfigurationModel struct {
1013-
OpensearchManagedClusterConfiguration fwtypes.ListNestedObjectValueOf[openSearchManagedClusterConfigurationModel] `tfsdk:"opensearch_managed_cluster_configuration"`
1014-
OpensearchServerlessConfiguration fwtypes.ListNestedObjectValueOf[openSearchServerlessConfigurationModel] `tfsdk:"opensearch_serverless_configuration"`
1105+
MongoDBAtlasConfiguration fwtypes.ListNestedObjectValueOf[mongoDBAtlasConfigurationModel] `tfsdk:"mongo_db_atlas_configuration"`
1106+
OpenSearchManagedClusterConfiguration fwtypes.ListNestedObjectValueOf[openSearchManagedClusterConfigurationModel] `tfsdk:"opensearch_managed_cluster_configuration"`
1107+
OpenSearchServerlessConfiguration fwtypes.ListNestedObjectValueOf[openSearchServerlessConfigurationModel] `tfsdk:"opensearch_serverless_configuration"`
10151108
PineconeConfiguration fwtypes.ListNestedObjectValueOf[pineconeConfigurationModel] `tfsdk:"pinecone_configuration"`
10161109
RDSConfiguration fwtypes.ListNestedObjectValueOf[rdsConfigurationModel] `tfsdk:"rds_configuration"`
10171110
RedisEnterpriseCloudConfiguration fwtypes.ListNestedObjectValueOf[redisEnterpriseCloudConfigurationModel] `tfsdk:"redis_enterprise_cloud_configuration"`
10181111
S3VectorsConfiguration fwtypes.ListNestedObjectValueOf[s3VectorsConfigurationModel] `tfsdk:"s3_vectors_configuration"`
10191112
Type fwtypes.StringEnum[awstypes.KnowledgeBaseStorageType] `tfsdk:"type"`
10201113
}
10211114

1115+
type mongoDBAtlasConfigurationModel struct {
1116+
CollectionName types.String `tfsdk:"collection_name"`
1117+
CredentialsSecretARN fwtypes.ARN `tfsdk:"credentials_secret_arn"`
1118+
DatabaseName types.String `tfsdk:"database_name"`
1119+
Endpoint types.String `tfsdk:"endpoint"`
1120+
EndpointServiceName types.String `tfsdk:"endpoint_service_name"`
1121+
FieldMapping fwtypes.ListNestedObjectValueOf[mongoDBAtlasFieldMappingModel] `tfsdk:"field_mapping"`
1122+
TextIndexName types.String `tfsdk:"text_index_name"`
1123+
VectorIndexName types.String `tfsdk:"vector_index_name"`
1124+
}
1125+
1126+
type mongoDBAtlasFieldMappingModel struct {
1127+
MetadataField types.String `tfsdk:"metadata_field"`
1128+
TextField types.String `tfsdk:"text_field"`
1129+
VectorField types.String `tfsdk:"vector_field"`
1130+
}
1131+
10221132
type openSearchManagedClusterConfigurationModel struct {
10231133
DomainARN fwtypes.ARN `tfsdk:"domain_arn"`
10241134
DomainEndpoint types.String `tfsdk:"domain_endpoint"`

internal/service/bedrockagent/knowledge_base_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ func testAccKnowledgeBase_OpenSearchManagedCluster_basic(t *testing.T) {
482482
})),
483483
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("storage_configuration"), knownvalue.ListExact([]knownvalue.Check{
484484
knownvalue.MapExact(map[string]knownvalue.Check{
485+
"mongo_db_atlas_configuration": knownvalue.ListSizeExact(0),
485486
"opensearch_managed_cluster_configuration": knownvalue.ListSizeExact(1),
486487
"opensearch_serverless_configuration": knownvalue.ListSizeExact(0),
487488
names.AttrType: tfknownvalue.StringExact(awstypes.KnowledgeBaseStorageTypeOpensearchManagedCluster),
@@ -525,6 +526,7 @@ func testAccKnowledgeBase_S3Vectors_update(t *testing.T) {
525526
ConfigStateChecks: []statecheck.StateCheck{
526527
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("storage_configuration"), knownvalue.ListExact([]knownvalue.Check{
527528
knownvalue.MapExact(map[string]knownvalue.Check{
529+
"mongo_db_atlas_configuration": knownvalue.ListSizeExact(0),
528530
"opensearch_managed_cluster_configuration": knownvalue.ListSizeExact(0),
529531
"opensearch_serverless_configuration": knownvalue.ListSizeExact(0),
530532
names.AttrType: tfknownvalue.StringExact(awstypes.KnowledgeBaseStorageTypeS3Vectors),

website/docs/r/bedrockagent_knowledge_base.html.markdown

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,31 @@ The `s3_location` configuration block supports the following arguments:
246246

247247
The `storage_configuration` configuration block supports the following arguments:
248248

249-
* `type` - (Required) Vector store service in which the knowledge base is stored. Valid Values: `OPENSEARCH_SERVERLESS`, `OPENSEARCH_MANAGED_CLUSTER`, `PINECONE`, `REDIS_ENTERPRISE_CLOUD`, `RDS`, `S3_VECTORS`.
249+
* `type` - (Required) Vector store service in which the knowledge base is stored. Valid Values: `MONGO_DB_ATLAS`, `OPENSEARCH_SERVERLESS`, `OPENSEARCH_MANAGED_CLUSTER`, `PINECONE`, `REDIS_ENTERPRISE_CLOUD`, `RDS`, `S3_VECTORS`.
250+
* `mongo_db_atlas_configuration` – (Optional) The storage configuration of the knowledge base in MongoDB Atlas. See [`opensearch_managed_cluster_comongo_db_atlas_configurationnfiguration` block](#mongo_db_atlas_configuration-block) for details.
250251
* `opensearch_managed_cluster_configuration` - (Optional) The storage configuration of the knowledge base in Amazon OpenSearch Service Managed Cluster. See [`opensearch_managed_cluster_configuration` block](#opensearch_managed_cluster_configuration-block) for details.
251252
* `opensearch_serverless_configuration` - (Optional) The storage configuration of the knowledge base in Amazon OpenSearch Service Serverless. See [`opensearch_serverless_configuration` block](#opensearch_serverless_configuration-block) for details.
252253
* `pinecone_configuration` - (Optional) The storage configuration of the knowledge base in Pinecone. See [`pinecone_configuration` block](#pinecone_configuration-block) for details.
253254
* `rds_configuration` - (Optional) Details about the storage configuration of the knowledge base in Amazon RDS. For more information, see [Create a vector index in Amazon RDS](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup.html). See [`rds_configuration` block](#rds_configuration-block) for details.
254255
* `redis_enterprise_cloud_configuration` - (Optional) The storage configuration of the knowledge base in Redis Enterprise Cloud. See [`redis_enterprise_cloud_configuration` block](#redis_enterprise_cloud_configuration-block) for details.
255256
* `s3_vectors_configuration` - (Optional) The storage configuration of the knowledge base in Amazon S3 Vectors. See [`s3_vectors_configuration` block](#s3_vectors_configuration-block) for details.
256257

258+
### `mongo_db_atlas_configuration` block
259+
260+
The `mongo_db_atlas_configuration` configuration block supports the following arguments:
261+
262+
* `collection_name` – (Required) The name of the collection in the MongoDB Atlas database.
263+
* `credentials_secret_arn` – (Required) The ARN of the secret that you created in AWS Secrets Manager that is linked to your MongoDB Atlas database.
264+
* `database_name` – (Required) The name of the database in the MongoDB Atlas database.
265+
* `endpoint` – (Required) The endpoint URL of the MongoDB Atlas database.
266+
* `field_mapping` – (Required) Contains the names of the fields to which to map information about the vector store.
267+
* `metadata_field` – (Required) The name of the field in which Amazon Bedrock stores metadata about the vector store.
268+
* `text_field` – (Required) The name of the field in which Amazon Bedrock stores the raw text from your data. The text is split according to the chunking strategy you choose.
269+
* `vector_field` – (Required) The name of the field in which Amazon Bedrock stores the vector embeddings for your data sources.
270+
* `vector_index_name` – (Required) The name of the vector index.
271+
* `endpoint_service_name` – (Optional) The name of the service that hosts the MongoDB Atlas database.
272+
* `text_index_name` – (Optional) The name of the vector index.
273+
257274
### `opensearch_managed_cluster_configuration` block
258275

259276
The `opensearch_managed_cluster_configuration` configuration block supports the following arguments:

0 commit comments

Comments
 (0)