Skip to content

Commit

Permalink
Merge pull request hashicorp#31823 from hashicorp/td-remove-AWSClient…
Browse files Browse the repository at this point in the history
….s3ConnURICleaningDisabled

Tech debt: Remove `AWSClient.s3ConnURICleaningDisabled`
  • Loading branch information
ewbankkit authored Jun 7, 2023
2 parents 2fabe5c + f9f8108 commit 347a53b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
9 changes: 7 additions & 2 deletions internal/conns/awsclient.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package conns

import (
"context"
"fmt"
"net/http"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/apigatewayv2"
"github.com/aws/aws-sdk-go/service/s3"
Expand All @@ -23,8 +25,11 @@ func (client *AWSClient) RegionalHostname(prefix string) string {
return fmt.Sprintf("%s.%s.%s", prefix, client.Region, client.DNSSuffix)
}

func (client *AWSClient) S3ConnURICleaningDisabled() *s3.S3 {
return client.s3ConnURICleaningDisabled
func (client *AWSClient) S3ConnURICleaningDisabled(context.Context) *s3.S3 {
config := client.S3Conn().Config
config.DisableRestProtocolURICleaning = aws.Bool(true)

return s3.New(client.Session.Copy(&config))
}

// SetHTTPClient sets the http.Client used for AWS API calls.
Expand Down
2 changes: 0 additions & 2 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS
}
client.s3Conn = s3.New(sess.Copy(s3Config))

s3Config.DisableRestProtocolURICleaning = aws.Bool(true)
client.s3ConnURICleaningDisabled = s3.New(sess.Copy(s3Config))

// "Global" services that require customizations.
globalAcceleratorConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.GlobalAccelerator]),
Expand Down
2 changes: 0 additions & 2 deletions internal/generate/awsclient/file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ type AWSClient struct {
{{ .ProviderPackage }}Client *{{ .GoV2Package }}.{{ .ClientTypeName }}
{{- end }}
{{- end }}

s3ConnURICleaningDisabled *s3.S3
}

{{ range .Services }}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ func resourceBucketDelete(ctx context.Context, d *schema.ResourceData, meta inte
// Use a S3 service client that can handle multiple slashes in URIs.
// While aws_s3_object resources cannot create these object
// keys, other AWS services and applications using the S3 Bucket can.
conn = meta.(*conns.AWSClient).S3ConnURICleaningDisabled()
conn := meta.(*conns.AWSClient).S3ConnURICleaningDisabled(ctx)

// bucket may have things delete them
log.Printf("[DEBUG] S3 Bucket attempting to forceDestroy %s", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/service/s3/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,7 @@ func testAccCheckBucketExistsWithProvider(ctx context.Context, n string, provide
func testAccCheckBucketAddObjects(ctx context.Context, n string, keys ...string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs := s.RootModule().Resources[n]
conn := acctest.Provider.Meta().(*conns.AWSClient).S3ConnURICleaningDisabled()
conn := acctest.Provider.Meta().(*conns.AWSClient).S3ConnURICleaningDisabled(ctx)

for _, key := range keys {
_, err := conn.PutObjectWithContext(ctx, &s3.PutObjectInput{
Expand Down
2 changes: 1 addition & 1 deletion internal/service/s3/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func sweepObjects(region string) error {
return fmt.Errorf("getting client: %s", err)
}

conn := client.(*conns.AWSClient).S3ConnURICleaningDisabled()
conn := client.(*conns.AWSClient).S3ConnURICleaningDisabled(ctx)
input := &s3.ListBucketsInput{}

output, err := conn.ListBucketsWithContext(ctx, input)
Expand Down

0 comments on commit 347a53b

Please sign in to comment.