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

resource/aws_bedrock_guardrail: Convert content_policy_config.filters_config to Set #40304

Merged
merged 2 commits into from
Nov 26, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/40304.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_bedrock_guardrail: Fix perpetual diff if multiple `content_policy_config.filters_config`s are specified.
```
6 changes: 3 additions & 3 deletions internal/service/bedrock/guardrail.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func (r *resourceGuardrail) Schema(ctx context.Context, req resource.SchemaReque
},
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"filters_config": schema.ListNestedBlock{
CustomType: fwtypes.NewListNestedObjectTypeOf[filtersConfig](ctx),
"filters_config": schema.SetNestedBlock{
CustomType: fwtypes.NewSetNestedObjectTypeOf[filtersConfig](ctx),
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"input_strength": schema.StringAttribute{
Expand Down Expand Up @@ -667,7 +667,7 @@ type resourceGuardrailData struct {
}

type contentPolicyConfig struct {
Filters fwtypes.ListNestedObjectValueOf[filtersConfig] `tfsdk:"filters_config"`
Filters fwtypes.SetNestedObjectValueOf[filtersConfig] `tfsdk:"filters_config"`
}

type filtersConfig struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/service/bedrock/guardrail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func TestAccBedrockGuardrail_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "blocked_outputs_messaging", "test"),
resource.TestCheckResourceAttr(resourceName, "content_policy_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "content_policy_config.0.filters_config.#", "2"),
resource.TestCheckResourceAttr(resourceName, "contextual_grounding_policy_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "contextual_grounding_policy_config.0.filters_config.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt),
resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "test"),
resource.TestCheckNoResourceAttr(resourceName, names.AttrKMSKeyARN),
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/bedrock_guardrail.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ The following arguments are optional:

The `content_policy_config` configuration block supports the following arguments:

* `filters_config` - (Optional) List of content filter configs in content policy. See [Filters Config](#content-filters-config) for more information.
* `filters_config` - (Optional) Set of content filter configs in content policy.
See [Filters Config](#content-filters-config) for more information.

#### Content Filters Config

Expand Down
Loading