Skip to content

Commit

Permalink
Merge pull request #36484 from LukasdeBoer/f-aws_eks_access_entry-bugfix
Browse files Browse the repository at this point in the history
Bugfix: Resource aws_eks_access_entry only updates group OR username
  • Loading branch information
ewbankkit authored Mar 20, 2024
2 parents b80c0c0 + 4c6e09f commit b53e946
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/36484.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_eks_access_entry: Always send `kubernetes_groups` and `user_name` values on update when configured
```
9 changes: 2 additions & 7 deletions internal/service/eks/access_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,8 @@ func resourceAccessEntryUpdate(ctx context.Context, d *schema.ResourceData, meta
PrincipalArn: aws.String(principalARN),
}

if d.HasChange("kubernetes_groups") {
input.KubernetesGroups = flex.ExpandStringValueSet(d.Get("kubernetes_groups").(*schema.Set))
}

if d.HasChange("user_name") {
input.Username = aws.String(d.Get("user_name").(string))
}
input.KubernetesGroups = flex.ExpandStringValueSet(d.Get("kubernetes_groups").(*schema.Set))
input.Username = aws.String(d.Get("user_name").(string))

_, err = conn.UpdateAccessEntry(ctx, input)

Expand Down
6 changes: 6 additions & 0 deletions internal/service/eks/access_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ func TestAccEKSAccessEntry_username(t *testing.T) {
Config: testAccAccessEntryConfig_username(rName, "user1"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAccessEntryExists(ctx, resourceName, &accessentry),
resource.TestCheckResourceAttr(resourceName, "kubernetes_groups.#", "1"),
resource.TestCheckTypeSetElemAttr(resourceName, "kubernetes_groups.*", "ae-test"),
resource.TestCheckResourceAttr(resourceName, "type", "STANDARD"),
resource.TestCheckResourceAttr(resourceName, "user_name", "user1"),
),
Expand All @@ -249,6 +251,8 @@ func TestAccEKSAccessEntry_username(t *testing.T) {
Config: testAccAccessEntryConfig_username(rName, "user2"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAccessEntryExists(ctx, resourceName, &accessentry),
resource.TestCheckResourceAttr(resourceName, "kubernetes_groups.#", "1"),
resource.TestCheckTypeSetElemAttr(resourceName, "kubernetes_groups.*", "ae-test"),
resource.TestCheckResourceAttr(resourceName, "type", "STANDARD"),
resource.TestCheckResourceAttr(resourceName, "user_name", "user2"),
),
Expand Down Expand Up @@ -528,6 +532,8 @@ resource "aws_eks_access_entry" "test" {
type = "STANDARD"
user_name = %[2]q
kubernetes_groups = ["ae-test"]
}
`, rName, username))
}

0 comments on commit b53e946

Please sign in to comment.