Skip to content

Commit

Permalink
Merge pull request #40304 from hashicorp/td-bedrock-guardrail-policy-…
Browse files Browse the repository at this point in the history
…sets

resource/aws_bedrock_guardrail: Convert `content_policy_config.filters_config` to Set
  • Loading branch information
gdavison authored Nov 26, 2024
2 parents 523ac85 + cb58eb0 commit dff0abb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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

0 comments on commit dff0abb

Please sign in to comment.