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

b/aws_kendra_index-user_group_resolution_configuration #31669

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/31669.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_kendra_index: Persist `user_group_resolution_mode` value to state after creation
```
2 changes: 1 addition & 1 deletion internal/service/kendra/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ func flattenUserGroupResolutionConfiguration(userGroupResolutionConfiguration *t
}

values := map[string]interface{}{
"user_group_resolution_configuration": userGroupResolutionConfiguration.UserGroupResolutionMode,
"user_group_resolution_mode": userGroupResolutionConfiguration.UserGroupResolutionMode,
}

return []interface{}{values}
Expand Down
57 changes: 57 additions & 0 deletions internal/service/kendra/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,48 @@ func TestAccKendraIndex_updateRoleARN(t *testing.T) {
})
}

func TestAccKendraIndex_updateUserGroupResolutionConfigurationMode(t *testing.T) {
ctx := acctest.Context(t)
var index kendra.DescribeIndexOutput

rName := sdkacctest.RandomWithPrefix("resource-test-terraform")
rName2 := sdkacctest.RandomWithPrefix("resource-test-terraform")
rName3 := sdkacctest.RandomWithPrefix("resource-test-terraform")
originalUserGroupResolutionMode := types.UserGroupResolutionModeAwsSso
updatedUserGroupResolutionMode := types.UserGroupResolutionModeNone
resourceName := "aws_kendra_index.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.KendraEndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckIndexDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccIndexConfig_userGroupResolutionMode(rName, rName2, rName3, string(originalUserGroupResolutionMode)),
Check: resource.ComposeTestCheckFunc(
testAccCheckIndexExists(ctx, resourceName, &index),
resource.TestCheckResourceAttr(resourceName, "user_group_resolution_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "user_group_resolution_configuration.0.user_group_resolution_mode", string(originalUserGroupResolutionMode)),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccIndexConfig_userGroupResolutionMode(rName, rName2, rName3, string(updatedUserGroupResolutionMode)),
Check: resource.ComposeTestCheckFunc(
testAccCheckIndexExists(ctx, resourceName, &index),
resource.TestCheckResourceAttr(resourceName, "user_group_resolution_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "user_group_resolution_configuration.0.user_group_resolution_mode", string(updatedUserGroupResolutionMode)),
),
},
},
})
}

func TestAccKendraIndex_addDocumentMetadataConfigurationUpdates(t *testing.T) {
ctx := acctest.Context(t)
var index kendra.DescribeIndexOutput
Expand Down Expand Up @@ -1555,6 +1597,21 @@ resource "aws_kendra_index" "test" {
`, rName3, groupAttributeField, userNameAttributeField))
}

func testAccIndexConfig_userGroupResolutionMode(rName, rName2, rName3, UserGroupResolutionMode string) string {
return acctest.ConfigCompose(
testAccIndexConfigBase(rName, rName2),
fmt.Sprintf(`
resource "aws_kendra_index" "test" {
name = %[1]q
role_arn = aws_iam_role.access_cw.arn

user_group_resolution_configuration {
user_group_resolution_mode = %[2]q
}
}
`, rName3, UserGroupResolutionMode))
}

func testAccIndexConfig_tags(rName, rName2, rName3, description string) string {
return acctest.ConfigCompose(
testAccIndexConfigBase(rName, rName2),
Expand Down
13 changes: 13 additions & 0 deletions website/docs/r/kendra_index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ resource "aws_kendra_index" "example" {
}
```

### With user group resolution configuration

```terraform
resource "aws_kendra_index" "example" {
name = "example"
role_arn = aws_iam_role.this.arn

user_group_resolution_configuration {
user_group_resolution_mode = "AWS_SSO"
}
}
```

### With Document Metadata Configuration Updates

#### Specifying the predefined elements
Expand Down