Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix by_provider regex for aws_bedrock_foundation_models data source #37306

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}