Skip to content

Commit

Permalink
Merge pull request #31669 from GlennChia/b-aws_kendra_index-user_grou…
Browse files Browse the repository at this point in the history
…p_resolution_configuration

b/aws_kendra_index-user_group_resolution_configuration
  • Loading branch information
ewbankkit authored May 31, 2023
2 parents ec0977c + e9b8654 commit 2586385
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
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

0 comments on commit 2586385

Please sign in to comment.