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

provider: go1.22.6 downgrade #39256

Merged
merged 12 commits into from
Sep 10, 2024
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/39256.txt
Original file line number Diff line number Diff line change
@@ -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.
```
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.23.0
1.22.6
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions internal/service/autoscaling/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports
"errors"
"fmt"
"log"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions internal/service/connect/routing_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/aws/aws-sdk-go-v2/aws"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/docdb/cluster_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"log"
"reflect"
"slices"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions internal/service/kafka/scram_secret_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions internal/service/lakeformation/lf_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"

"github.com/YakDriver/regexache"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/neptune/cluster_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions internal/service/neptune/parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"slices"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/service/rds/cluster_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion internal/service/route53/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 9 additions & 5 deletions internal/service/ssm/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"log"
"regexp"
"slices"
"strings"
"time"

Expand All @@ -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"
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand All @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down
17 changes: 17 additions & 0 deletions internal/slices/slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading
Loading