Skip to content

Commit

Permalink
fix: Fix by_provider regex for aws_bedrock_foundation_models data source
Browse files Browse the repository at this point in the history
  • Loading branch information
acwwat committed May 7, 2024
1 parent 3a7abcd commit 3ad5c7f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/service/bedrock/foundation_models_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (d *foundationModelsDataSource) Schema(ctx context.Context, request datasou
"by_provider": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexache.MustCompile(`^[a-z0-9-]{1,63}$`), ""),
stringvalidator.RegexMatches(regexache.MustCompile(`^[A-Za-z0-9- ]{1,63}$`), ""),
},
},
names.AttrID: framework.IDAttribute(),
Expand Down
29 changes: 29 additions & 0 deletions internal/service/bedrock/foundation_models_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ func TestAccBedrockFoundationModelsDataSource_byOutputModality(t *testing.T) {
})
}

func TestAccBedrockFoundationModelsDataSource_byProvider(t *testing.T) {
ctx := acctest.Context(t)
datasourceName := "data.aws_bedrock_foundation_models.test"
provider := "Mistral AI"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, names.BedrockEndpointID) },
ErrorCheck: acctest.ErrorCheck(t, names.BedrockServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccFoundationModelsDataSourceConfig_byProvider(provider),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(datasourceName, "id"),
acctest.CheckResourceAttrGreaterThanValue(datasourceName, "model_summaries.#", 0),
),
},
},
})
}

func testAccFoundationModelsDataSourceConfig_basic() string {
return `
data "aws_bedrock_foundation_models" "test" {}
Expand Down Expand Up @@ -122,3 +143,11 @@ data "aws_bedrock_foundation_models" "test" {
}
`, outputModality)
}

func testAccFoundationModelsDataSourceConfig_byProvider(provider string) string {
return fmt.Sprintf(`
data "aws_bedrock_foundation_models" "test" {
by_provider = %[1]q
}
`, provider)
}

0 comments on commit 3ad5c7f

Please sign in to comment.