Skip to content

Commit

Permalink
Replace 'tfslices.Chunks' with 'slices.Chunk' - ssm.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Sep 4, 2024
1 parent f722b5d commit 281ea60
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions internal/service/ssm/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"log"
"regexp"
"slices"
"strings"
"time"

Expand All @@ -27,7 +28,6 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
"github.com/hashicorp/terraform-provider-aws/internal/flex"
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
Expand Down Expand Up @@ -290,9 +290,7 @@ func resourceDocumentCreate(ctx context.Context, d *schema.ResourceData, meta in
tfMap := flex.ExpandStringValueMap(v.(map[string]interface{}))

if v, ok := tfMap["account_ids"]; ok && v != "" {
chunks := tfslices.Chunks(strings.Split(v, ","), documentPermissionsBatchLimit)

for _, chunk := range chunks {
for chunk := range slices.Chunk(strings.Split(v, ","), documentPermissionsBatchLimit) {
input := &ssm.ModifyDocumentPermissionInput{
AccountIdsToAdd: chunk,
Name: aws.String(d.Id()),
Expand Down Expand Up @@ -426,7 +424,7 @@ func resourceDocumentUpdate(ctx context.Context, d *schema.ResourceData, meta in
}
}

for _, chunk := range tfslices.Chunks(newAccountIDs.Difference(oldAccountIDs), documentPermissionsBatchLimit) {
for chunk := range slices.Chunk(newAccountIDs.Difference(oldAccountIDs), documentPermissionsBatchLimit) {
input := &ssm.ModifyDocumentPermissionInput{
AccountIdsToAdd: chunk,
Name: aws.String(d.Id()),
Expand All @@ -440,7 +438,7 @@ func resourceDocumentUpdate(ctx context.Context, d *schema.ResourceData, meta in
}
}

for _, chunk := range tfslices.Chunks(oldAccountIDs.Difference(newAccountIDs), documentPermissionsBatchLimit) {
for chunk := range slices.Chunk(oldAccountIDs.Difference(newAccountIDs), documentPermissionsBatchLimit) {
input := &ssm.ModifyDocumentPermissionInput{
AccountIdsToRemove: chunk,
Name: aws.String(d.Id()),
Expand Down Expand Up @@ -517,9 +515,7 @@ func resourceDocumentDelete(ctx context.Context, d *schema.ResourceData, meta in
tfMap := flex.ExpandStringValueMap(v.(map[string]interface{}))

if v, ok := tfMap["account_ids"]; ok && v != "" {
chunks := tfslices.Chunks(strings.Split(v, ","), documentPermissionsBatchLimit)

for _, chunk := range chunks {
for chunk := range slices.Chunk(strings.Split(v, ","), documentPermissionsBatchLimit) {
input := &ssm.ModifyDocumentPermissionInput{
AccountIdsToRemove: chunk,
Name: aws.String(d.Id()),
Expand Down

0 comments on commit 281ea60

Please sign in to comment.