From 8ef55734c7f53f95434d1078030dddc68cb92d84 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:19:32 -0400 Subject: [PATCH 01/12] chore: revert to go1.22.6 A small number of users have reported failed or hanging network connections using the version of the Terraform AWS provider which was first built with Go `1.23.0` (`v5.65.0`). At this point, maintainers have been unable to reproduce failures, but enough distinct users have reported issues that we are going to attempt downgrading to Go `1.22.6` for the next provider release. We will continue to coordinate with users and AWS in an attempt to identify the root cause, using this upcoming release with a reverted Go build version as a data point. --- .go-version | 2 +- go.mod | 2 +- skaff/go.mod | 2 +- tools/awssdkpatch/go.mod | 2 +- tools/tfsdk2fw/go.mod | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.go-version b/.go-version index a6c2798a482e..013173af5e9b 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.23.0 +1.22.6 diff --git a/go.mod b/go.mod index 3fe9a05c0d86..394a53016d56 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/terraform-provider-aws -go 1.23.0 +go 1.22.6 require ( github.com/ProtonMail/go-crypto v1.1.0-alpha.5-proton diff --git a/skaff/go.mod b/skaff/go.mod index 7a6fb532491a..ee72fb23b438 100644 --- a/skaff/go.mod +++ b/skaff/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/terraform-provider-aws/skaff -go 1.23.0 +go 1.22.6 require ( github.com/YakDriver/regexache v0.24.0 diff --git a/tools/awssdkpatch/go.mod b/tools/awssdkpatch/go.mod index e0ecf587abee..809a5404d595 100644 --- a/tools/awssdkpatch/go.mod +++ b/tools/awssdkpatch/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/terraform-provider-aws/tools/awssdkpatch -go 1.23.0 +go 1.22.6 require ( github.com/hashicorp/terraform-provider-aws v1.60.1-0.20220322001452-8f7a597d0c24 diff --git a/tools/tfsdk2fw/go.mod b/tools/tfsdk2fw/go.mod index ceb2a351bd92..d3096c4fca0c 100644 --- a/tools/tfsdk2fw/go.mod +++ b/tools/tfsdk2fw/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/terraform-provider-aws/tools/tfsdk2fw -go 1.23.0 +go 1.22.6 require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 From 9be946fa22ed578bcf3beb25c76b2c9e3ee52e0a Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:24:49 -0400 Subject: [PATCH 02/12] Revert "Remove 'tfslices.Chunks'." This reverts commit e5c24d5d41a5d074b679074e6091c9f2583e88e6. --- internal/slices/slices.go | 17 +++++++++++++++ internal/slices/slices_test.go | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/internal/slices/slices.go b/internal/slices/slices.go index f35b30007b38..dccfa9f3814a 100644 --- a/internal/slices/slices.go +++ b/internal/slices/slices.go @@ -100,6 +100,23 @@ func Any[S ~[]E, E any](s S, f Predicate[E]) bool { return false } +// Chunks returns a slice of S, each of the specified size (or less). +func Chunks[S ~[]E, E any](s S, size int) []S { + chunks := make([]S, 0) + + for i := 0; i < len(s); i += size { + end := i + size + + if end > len(s) { + end = len(s) + } + + chunks = append(chunks, s[i:end]) + } + + return chunks +} + // AppendUnique appends unique (not already in the slice) values to a slice. func AppendUnique[S ~[]E, E comparable](s S, vs ...E) S { for _, v := range vs { diff --git a/internal/slices/slices_test.go b/internal/slices/slices_test.go index 0537d29f2cfd..35ea97b2621a 100644 --- a/internal/slices/slices_test.go +++ b/internal/slices/slices_test.go @@ -153,6 +153,45 @@ func TestApplyToAll(t *testing.T) { } } +func TestChunk(t *testing.T) { + t.Parallel() + + type testCase struct { + input []string + expected [][]string + } + tests := map[string]testCase{ + "three elements": { + input: []string{"one", "two", "3"}, + expected: [][]string{{"one", "two"}, {"3"}}, + }, + "two elements": { + input: []string{"aa", "bb"}, + expected: [][]string{{"aa", "bb"}}, + }, + "one element": { + input: []string{"1"}, + expected: [][]string{{"1"}}, + }, + "zero elements": { + input: []string{}, + expected: [][]string{}, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + got := Chunks(test.input, 2) + + if diff := cmp.Diff(got, test.expected); diff != "" { + t.Errorf("unexpected diff (+wanted, -got): %s", diff) + } + }) + } +} + func TestFilter(t *testing.T) { t.Parallel() From bfff87fb6e7dd8edb768efd0e87cb82ab9e9db92 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:25:26 -0400 Subject: [PATCH 03/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - ssm." This reverts commit 281ea608c590a18d129c964087de2fea415b965b. --- internal/service/ssm/document.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/service/ssm/document.go b/internal/service/ssm/document.go index ef17345d0e3d..e6ed152e1426 100644 --- a/internal/service/ssm/document.go +++ b/internal/service/ssm/document.go @@ -9,7 +9,6 @@ import ( "fmt" "log" "regexp" - "slices" "strings" "time" @@ -28,6 +27,7 @@ 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" @@ -290,7 +290,9 @@ 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 != "" { - for chunk := range slices.Chunk(strings.Split(v, ","), documentPermissionsBatchLimit) { + chunks := tfslices.Chunks(strings.Split(v, ","), documentPermissionsBatchLimit) + + for _, chunk := range chunks { input := &ssm.ModifyDocumentPermissionInput{ AccountIdsToAdd: chunk, Name: aws.String(d.Id()), @@ -424,7 +426,7 @@ func resourceDocumentUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - for chunk := range slices.Chunk(newAccountIDs.Difference(oldAccountIDs), documentPermissionsBatchLimit) { + for _, chunk := range tfslices.Chunks(newAccountIDs.Difference(oldAccountIDs), documentPermissionsBatchLimit) { input := &ssm.ModifyDocumentPermissionInput{ AccountIdsToAdd: chunk, Name: aws.String(d.Id()), @@ -438,7 +440,7 @@ func resourceDocumentUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - for chunk := range slices.Chunk(oldAccountIDs.Difference(newAccountIDs), documentPermissionsBatchLimit) { + for _, chunk := range tfslices.Chunks(oldAccountIDs.Difference(newAccountIDs), documentPermissionsBatchLimit) { input := &ssm.ModifyDocumentPermissionInput{ AccountIdsToRemove: chunk, Name: aws.String(d.Id()), @@ -515,7 +517,9 @@ 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 != "" { - for chunk := range slices.Chunk(strings.Split(v, ","), documentPermissionsBatchLimit) { + chunks := tfslices.Chunks(strings.Split(v, ","), documentPermissionsBatchLimit) + + for _, chunk := range chunks { input := &ssm.ModifyDocumentPermissionInput{ AccountIdsToRemove: chunk, Name: aws.String(d.Id()), From d1b3b11504ed55bc360aa059371882db76a1481f Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:25:41 -0400 Subject: [PATCH 04/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - route53." This reverts commit f722b5d063c2b50fee2812a8f784a5c803e88553. --- internal/service/route53/zone.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/service/route53/zone.go b/internal/service/route53/zone.go index 940e3bf78db7..15edc9f2afbb 100644 --- a/internal/service/route53/zone.go +++ b/internal/service/route53/zone.go @@ -383,7 +383,8 @@ func deleteAllResourceRecordsFromHostedZone(ctx context.Context, conn *route53.C const ( chunkSize = 100 ) - for chunk := range slices.Chunk(resourceRecordSets, chunkSize) { + chunks := tfslices.Chunks(resourceRecordSets, chunkSize) + for _, chunk := range chunks { changes := tfslices.ApplyToAll(chunk, func(v awstypes.ResourceRecordSet) awstypes.Change { return awstypes.Change{ Action: awstypes.ChangeActionDelete, From 0c6c6379093307002b662b2aa508db46894b3344 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:25:59 -0400 Subject: [PATCH 05/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - rds." This reverts commit ed58544991f7499e6aeec7721248693cd5047a55. --- internal/service/rds/cluster_parameter_group.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/rds/cluster_parameter_group.go b/internal/service/rds/cluster_parameter_group.go index 28a4a0c6ae00..ccfdc6bfcdcd 100644 --- a/internal/service/rds/cluster_parameter_group.go +++ b/internal/service/rds/cluster_parameter_group.go @@ -208,7 +208,7 @@ func resourceClusterParameterGroupUpdate(ctx context.Context, d *schema.Resource o, n := d.GetChange(names.AttrParameter) os, ns := o.(*schema.Set), n.(*schema.Set) - for chunk := range slices.Chunk(expandParameters(ns.Difference(os).List()), maxParamModifyChunk) { + for _, chunk := range tfslices.Chunks(expandParameters(ns.Difference(os).List()), maxParamModifyChunk) { input := &rds.ModifyDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(d.Id()), Parameters: chunk, @@ -236,7 +236,7 @@ func resourceClusterParameterGroupUpdate(ctx context.Context, d *schema.Resource } // Reset parameters that have been removed. - for chunk := range slices.Chunk(maps.Values(toRemove), maxParamModifyChunk) { + for _, chunk := range tfslices.Chunks(maps.Values(toRemove), maxParamModifyChunk) { input := &rds.ResetDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(d.Id()), Parameters: chunk, From 8ec86706b4c8daa79bb5a18ba9b925f6d401ead4 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:26:31 -0400 Subject: [PATCH 06/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - neptune." This reverts commit d42525b78a10d9460062937bdf794c17cbcb642e. --- internal/service/neptune/cluster_parameter_group.go | 2 +- internal/service/neptune/parameter_group.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/neptune/cluster_parameter_group.go b/internal/service/neptune/cluster_parameter_group.go index b31cd660ef40..aa63ef7b8a86 100644 --- a/internal/service/neptune/cluster_parameter_group.go +++ b/internal/service/neptune/cluster_parameter_group.go @@ -242,7 +242,7 @@ func modifyClusterParameterGroupParameters(ctx context.Context, conn *neptune.Cl clusterParameterGroupMaxParamsBulkEdit = 20 ) // We can only modify 20 parameters at a time, so chunk them until we've got them all. - for chunk := range slices.Chunk(parameters, clusterParameterGroupMaxParamsBulkEdit) { + for _, chunk := range tfslices.Chunks(parameters, clusterParameterGroupMaxParamsBulkEdit) { input := &neptune.ModifyDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(name), Parameters: chunk, diff --git a/internal/service/neptune/parameter_group.go b/internal/service/neptune/parameter_group.go index df81d7c11bb3..0c8e05589a27 100644 --- a/internal/service/neptune/parameter_group.go +++ b/internal/service/neptune/parameter_group.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "log" - "slices" "time" "github.com/aws/aws-sdk-go-v2/aws" @@ -21,6 +20,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + 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" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -226,7 +226,7 @@ func resourceParameterGroupDelete(ctx context.Context, d *schema.ResourceData, m } func addDBParameterGroupParameters(ctx context.Context, conn *neptune.Client, name string, parameters []awstypes.Parameter) error { // We can only modify 20 parameters at a time, so chunk them until we've got them all. - for chunk := range slices.Chunk(parameters, dbParameterGroupMaxParamsBulkEdit) { + for _, chunk := range tfslices.Chunks(parameters, dbParameterGroupMaxParamsBulkEdit) { input := &neptune.ModifyDBParameterGroupInput{ DBParameterGroupName: aws.String(name), Parameters: chunk, @@ -243,7 +243,7 @@ func addDBParameterGroupParameters(ctx context.Context, conn *neptune.Client, na } func delDBParameterGroupParameters(ctx context.Context, conn *neptune.Client, name string, parameters []awstypes.Parameter) error { // We can only modify 20 parameters at a time, so chunk them until we've got them all. - for chunk := range slices.Chunk(parameters, dbParameterGroupMaxParamsBulkEdit) { + for _, chunk := range tfslices.Chunks(parameters, dbParameterGroupMaxParamsBulkEdit) { input := &neptune.ResetDBParameterGroupInput{ DBParameterGroupName: aws.String(name), Parameters: chunk, From f797f26abda449445c7bd4f3ff41a3bb67eae0d7 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:27:39 -0400 Subject: [PATCH 07/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - kafka." This reverts commit 623df99664096370f5bc7eb85d215cc1fc7b96ed. --- internal/service/kafka/scram_secret_association.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/kafka/scram_secret_association.go b/internal/service/kafka/scram_secret_association.go index 51d96cad1398..183e5017647d 100644 --- a/internal/service/kafka/scram_secret_association.go +++ b/internal/service/kafka/scram_secret_association.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "log" - "slices" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/kafka" @@ -20,6 +19,7 @@ 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" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" ) @@ -163,7 +163,7 @@ func findSCRAMSecretsByClusterARN(ctx context.Context, conn *kafka.Client, clust } func associateSRAMSecrets(ctx context.Context, conn *kafka.Client, clusterARN string, secretARNs []string) error { - for chunk := range slices.Chunk(secretARNs, scramSecretBatchSize) { + for _, chunk := range tfslices.Chunks(secretARNs, scramSecretBatchSize) { input := &kafka.BatchAssociateScramSecretInput{ ClusterArn: aws.String(clusterARN), SecretArnList: chunk, @@ -184,7 +184,7 @@ func associateSRAMSecrets(ctx context.Context, conn *kafka.Client, clusterARN st } func disassociateSRAMSecrets(ctx context.Context, conn *kafka.Client, clusterARN string, secretARNs []string) error { - for chunk := range slices.Chunk(secretARNs, scramSecretBatchSize) { + for _, chunk := range tfslices.Chunks(secretARNs, scramSecretBatchSize) { input := &kafka.BatchDisassociateScramSecretInput{ ClusterArn: aws.String(clusterARN), SecretArnList: chunk, From 9ec42d9acef0315850cdb05af83e6bd733f64ddd Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:27:54 -0400 Subject: [PATCH 08/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - docdb." This reverts commit 7d5e3108899b86dd9b09272c3650f67cc4084cd9. --- internal/service/docdb/cluster_parameter_group.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/docdb/cluster_parameter_group.go b/internal/service/docdb/cluster_parameter_group.go index 910dec1a1bb2..d530b2a85c2d 100644 --- a/internal/service/docdb/cluster_parameter_group.go +++ b/internal/service/docdb/cluster_parameter_group.go @@ -8,7 +8,6 @@ import ( "fmt" "log" "reflect" - "slices" "time" "github.com/aws/aws-sdk-go-v2/aws" @@ -22,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + 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" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -226,7 +226,7 @@ func modifyClusterParameterGroupParameters(ctx context.Context, conn *docdb.Clie clusterParameterGroupMaxParamsBulkEdit = 20 ) // We can only modify 20 parameters at a time, so chunk them until we've got them all. - for chunk := range slices.Chunk(parameters, clusterParameterGroupMaxParamsBulkEdit) { + for _, chunk := range tfslices.Chunks(parameters, clusterParameterGroupMaxParamsBulkEdit) { input := &docdb.ModifyDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(name), Parameters: chunk, From c40facf120ddc512ef0f41f047a386abbfc4b7c5 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:28:10 -0400 Subject: [PATCH 09/12] Revert "Replace 'tfslices.Chunks' with 'slices.Chunk' - connect." This reverts commit e56ae32b1ccfc14a694144d3e736f39709af8fe1. --- internal/service/connect/routing_profile.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/service/connect/routing_profile.go b/internal/service/connect/routing_profile.go index 791bd07429e0..1ed8dd8413da 100644 --- a/internal/service/connect/routing_profile.go +++ b/internal/service/connect/routing_profile.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "log" - "slices" "strings" "github.com/aws/aws-sdk-go-v2/aws" @@ -21,6 +20,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + 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" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -361,7 +361,8 @@ func updateRoutingProfileQueueAssociations(ctx context.Context, conn *connect.Cl // the respective queues based on the diff detected // disassociate first since Queue and channel type combination cannot be duplicated - for chunk := range slices.Chunk(del, routingProfileQueueAssociationChunkSize) { + chunks := tfslices.Chunks(del, routingProfileQueueAssociationChunkSize) + for _, chunk := range chunks { var queueReferences []awstypes.RoutingProfileQueueReference for _, v := range chunk { if v := v.QueueReference; v != nil { @@ -384,7 +385,8 @@ func updateRoutingProfileQueueAssociations(ctx context.Context, conn *connect.Cl } } - for chunk := range slices.Chunk(add, routingProfileQueueAssociationChunkSize) { + chunks = tfslices.Chunks(add, routingProfileQueueAssociationChunkSize) + for _, chunk := range chunks { input := &connect.AssociateRoutingProfileQueuesInput{ InstanceId: aws.String(instanceID), QueueConfigs: chunk, From b142d284c98b4bee25a52190664538ba483cb913 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 14:34:48 -0400 Subject: [PATCH 10/12] Partial reversion of Replace 'tfslices.Chunks' with 'slices.Chunk' - lakeformation. ```console % make testacc TESTARGS='-run=TestAccLakeFormation_serial/^LFTags$$' PKG=lakeformation make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.6 test ./internal/service/lakeformation/... -v -count 1 -parallel 20 -run=TestAccLakeFormation_serial/^LFTags$ -timeout 360m --- PASS: TestAccLakeFormation_serial (97.10s) --- PASS: TestAccLakeFormation_serial/LFTags (97.10s) --- PASS: TestAccLakeFormation_serial/LFTags/basic (15.97s) --- PASS: TestAccLakeFormation_serial/LFTags/disappears (13.05s) --- PASS: TestAccLakeFormation_serial/LFTags/tagKeyComplex (12.14s) --- PASS: TestAccLakeFormation_serial/LFTags/values (24.46s) --- PASS: TestAccLakeFormation_serial/LFTags/valuesOverFifty (31.49s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation 103.355s ``` --- internal/service/lakeformation/lf_tag.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/lakeformation/lf_tag.go b/internal/service/lakeformation/lf_tag.go index 507d271e1bd0..c083d1e9cace 100644 --- a/internal/service/lakeformation/lf_tag.go +++ b/internal/service/lakeformation/lf_tag.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "log" - "slices" "strings" "github.com/YakDriver/regexache" @@ -21,6 +20,7 @@ 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" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -83,7 +83,7 @@ func resourceLFTagCreate(ctx context.Context, d *schema.ResourceData, meta inter id := lfTagCreateResourceID(catalogID, tagKey) i := 0 - for chunk := range slices.Chunk(tagValues.List(), lfTagsValuesMaxBatchSize) { + for _, chunk := range tfslices.Chunks(tagValues.List(), lfTagsValuesMaxBatchSize) { if i == 0 { input := &lakeformation.CreateLFTagInput{ CatalogId: aws.String(catalogID), @@ -169,11 +169,11 @@ func resourceLFTagUpdate(ctx context.Context, d *schema.ResourceData, meta inter var toAddChunks, toDeleteChunks [][]interface{} if len(toAdd.List()) > 0 { - toAddChunks = slices.Collect(slices.Chunk(toAdd.List(), lfTagsValuesMaxBatchSize)) + toAddChunks = tfslices.Chunks(toAdd.List(), lfTagsValuesMaxBatchSize) } if len(toDelete.List()) > 0 { - toDeleteChunks = slices.Collect(slices.Chunk(toDelete.List(), lfTagsValuesMaxBatchSize)) + toDeleteChunks = tfslices.Chunks(toDelete.List(), lfTagsValuesMaxBatchSize) } for { From a351eb1736cbe5d0d4debf28195cfb4998709c93 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 11:40:02 -0400 Subject: [PATCH 11/12] Partial reversion of Replace 'tfslices.Chunks' with 'slices.Chunk' - autoscaling. ```console % make testacc TESTARGS='-run=TestAccAutoScalingGroup_basic\|TestAccAutoScalingGroup_withTrafficSourcesELBs\|TestAccAutoScalingGroup_loadBalancers\|TestAccAutoScalingGroup_targetGroups' PKG=autoscaling make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.22.6 test ./internal/service/autoscaling/... -v -count 1 -parallel 20 -run=TestAccAutoScalingGroup_basic\|TestAccAutoScalingGroup_withTrafficSourcesELBs\|TestAccAutoScalingGroup_loadBalancers\|TestAccAutoScalingGroup_targetGroups -timeout 360m --- PASS: TestAccAutoScalingGroup_basic (28.41s) --- PASS: TestAccAutoScalingGroup_targetGroups (108.44s) --- PASS: TestAccAutoScalingGroup_loadBalancers (287.88s) --- PASS: TestAccAutoScalingGroup_withTrafficSourcesELBs (374.16s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/autoscaling 380.382s ``` --- internal/service/autoscaling/group.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 6765fcb0f583..9b79e8687b0e 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -8,7 +8,6 @@ import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports "errors" "fmt" "log" - "slices" "strconv" "strings" "time" @@ -35,6 +34,7 @@ import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" "github.com/hashicorp/terraform-provider-aws/internal/sdkv2/types/nullable" + tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -1504,7 +1504,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter // API only supports adding or removing 10 at a time. batchSize := 10 - for chunk := range slices.Chunk(expandTrafficSourceIdentifiers(os.Difference(ns).List()), batchSize) { + for _, chunk := range tfslices.Chunks(expandTrafficSourceIdentifiers(os.Difference(ns).List()), batchSize) { input := &autoscaling.DetachTrafficSourcesInput{ AutoScalingGroupName: aws.String(d.Id()), TrafficSources: chunk, @@ -1521,7 +1521,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter } } - for chunk := range slices.Chunk(expandTrafficSourceIdentifiers(ns.Difference(os).List()), batchSize) { + for _, chunk := range tfslices.Chunks(expandTrafficSourceIdentifiers(ns.Difference(os).List()), batchSize) { input := &autoscaling.AttachTrafficSourcesInput{ AutoScalingGroupName: aws.String(d.Id()), TrafficSources: chunk, @@ -1545,7 +1545,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter // API only supports adding or removing 10 at a time. batchSize := 10 - for chunk := range slices.Chunk(flex.ExpandStringValueSet(os.Difference(ns)), batchSize) { + for _, chunk := range tfslices.Chunks(flex.ExpandStringValueSet(os.Difference(ns)), batchSize) { input := &autoscaling.DetachLoadBalancersInput{ AutoScalingGroupName: aws.String(d.Id()), LoadBalancerNames: chunk, @@ -1562,7 +1562,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter } } - for chunk := range slices.Chunk(flex.ExpandStringValueSet(ns.Difference(os)), batchSize) { + for _, chunk := range tfslices.Chunks(flex.ExpandStringValueSet(ns.Difference(os)), batchSize) { input := &autoscaling.AttachLoadBalancersInput{ AutoScalingGroupName: aws.String(d.Id()), LoadBalancerNames: chunk, @@ -1586,7 +1586,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter // API only supports adding or removing 10 at a time. batchSize := 10 - for chunk := range slices.Chunk(flex.ExpandStringValueSet(os.Difference(ns)), batchSize) { + for _, chunk := range tfslices.Chunks(flex.ExpandStringValueSet(os.Difference(ns)), batchSize) { input := &autoscaling.DetachLoadBalancerTargetGroupsInput{ AutoScalingGroupName: aws.String(d.Id()), TargetGroupARNs: chunk, @@ -1603,7 +1603,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter } } - for chunk := range slices.Chunk(flex.ExpandStringValueSet(ns.Difference(os)), batchSize) { + for _, chunk := range tfslices.Chunks(flex.ExpandStringValueSet(ns.Difference(os)), batchSize) { input := &autoscaling.AttachLoadBalancerTargetGroupsInput{ AutoScalingGroupName: aws.String(d.Id()), TargetGroupARNs: chunk, @@ -1864,7 +1864,7 @@ func drainGroup(ctx context.Context, conn *autoscaling.Client, name string, inst } } const batchSize = 50 // API limit. - for chunk := range slices.Chunk(instanceIDs, batchSize) { + for _, chunk := range tfslices.Chunks(instanceIDs, batchSize) { input := &autoscaling.SetInstanceProtectionInput{ AutoScalingGroupName: aws.String(name), InstanceIds: chunk, From 0f552d30fbfe12dcdadfe7e1469d3494d6bbb08d Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Tue, 10 Sep 2024 15:57:40 -0400 Subject: [PATCH 12/12] chore: changelog --- .changelog/39256.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/39256.txt diff --git a/.changelog/39256.txt b/.changelog/39256.txt new file mode 100644 index 000000000000..9aaabfda5da3 --- /dev/null +++ b/.changelog/39256.txt @@ -0,0 +1,3 @@ +```release-note:note +provider: Downgrades to Go `1.22.6`. A small number of users have reported failed or hanging network connections using the version of the Terraform AWS provider which was first built with Go `1.23.0` (`v5.65.0`). At this point, maintainers have been unable to reproduce failures, but enough distinct users have reported issues that we are going to attempt downgrading to Go `1.22.6` for the next provider release. We will continue to coordinate with users and AWS in an attempt to identify the root cause, using this upcoming release with a reverted Go build version as a data point. +```