Skip to content

Commit

Permalink
Merge pull request #37306 from acwwat/b-aws_bedrock_foundational_mode…
Browse files Browse the repository at this point in the history
…ls-fix_data_source_provider_regex

fix: Fix by_provider regex for aws_bedrock_foundation_models data source
  • Loading branch information
ewbankkit committed May 13, 2024
2 parents 8f12c5c + a8dba3f commit 805ca6d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/37306.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
data-source/aws_bedrock_foundation_models: Fix validation regex for the `by_provider` argument
```
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 805ca6d

Please sign in to comment.