From 39d10afce9d5778bf9211930ebad16099759e999 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Mon, 25 Nov 2024 17:35:12 -0800 Subject: [PATCH 1/2] Converts `content_policy_config.filters_config` to Set --- internal/service/bedrock/guardrail.go | 6 +++--- internal/service/bedrock/guardrail_test.go | 2 ++ website/docs/r/bedrock_guardrail.html.markdown | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/service/bedrock/guardrail.go b/internal/service/bedrock/guardrail.go index 04e3c61c219..f2c70aa5a19 100644 --- a/internal/service/bedrock/guardrail.go +++ b/internal/service/bedrock/guardrail.go @@ -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{ @@ -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 { diff --git a/internal/service/bedrock/guardrail_test.go b/internal/service/bedrock/guardrail_test.go index 50b38161c06..c1e85f5eb9b 100644 --- a/internal/service/bedrock/guardrail_test.go +++ b/internal/service/bedrock/guardrail_test.go @@ -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), diff --git a/website/docs/r/bedrock_guardrail.html.markdown b/website/docs/r/bedrock_guardrail.html.markdown index 8aeefbfccf7..158d7f5ab89 100644 --- a/website/docs/r/bedrock_guardrail.html.markdown +++ b/website/docs/r/bedrock_guardrail.html.markdown @@ -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 From cb58eb066d921a81e5119523f4033a9180093366 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 26 Nov 2024 09:57:01 -0800 Subject: [PATCH 2/2] Adds CHANGELOG entry --- .changelog/40304.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/40304.txt diff --git a/.changelog/40304.txt b/.changelog/40304.txt new file mode 100644 index 00000000000..955eb174739 --- /dev/null +++ b/.changelog/40304.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_bedrock_guardrail: Fix perpetual diff if multiple `content_policy_config.filters_config`s are specified. +```