@@ -4,16 +4,16 @@ import (
44 "context"
55 "errors"
66 "fmt"
7+ "log"
78 "net/http"
89 "regexp"
910 "strings"
1011 "time"
1112
1213 "github.com/aws/aws-sdk-go-v2/config"
13- awsType "github.com/aws/aws-sdk-go-v2/service/sqs/types"
14-
1514 "github.com/aws/aws-sdk-go-v2/credentials"
1615 "github.com/aws/aws-sdk-go-v2/service/sqs"
16+ awstype "github.com/aws/aws-sdk-go-v2/service/sqs/types"
1717 smithylogging "github.com/aws/smithy-go/logging"
1818 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
1919 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
@@ -39,11 +39,11 @@ type httpDebugLogger struct{}
3939
4040func (h * httpDebugLogger ) Logf (classification smithylogging.Classification , format string , v ... interface {}) {
4141 if classification == smithylogging .Debug {
42- fmt .Printf ("[HTTP DEBUG] %s\n " , fmt .Sprintf (format , v ... ))
42+ log .Printf ("[HTTP DEBUG] %s" , fmt .Sprintf (format , v ... ))
4343 }
4444}
4545
46- func SQSClientWithRegion (d * schema.ResourceData , m interface {}) (* sqs.Client , scw.Region , error ) {
46+ func SQSClientWithRegion (ctx context. Context , d * schema.ResourceData , m interface {}) (* sqs.Client , scw.Region , error ) {
4747 region , err := meta .ExtractRegion (d , m )
4848 if err != nil {
4949 return nil , "" , err
@@ -53,18 +53,18 @@ func SQSClientWithRegion(d *schema.ResourceData, m interface{}) (*sqs.Client, sc
5353 accessKey := d .Get ("access_key" ).(string )
5454 secretKey := d .Get ("secret_key" ).(string )
5555
56- sqsClient , err := NewSQSClient (meta .ExtractHTTPClient (m ), region .String (), endpoint , accessKey , secretKey )
56+ sqsClient , err := NewSQSClient (ctx , meta .ExtractHTTPClient (m ), region .String (), endpoint , accessKey , secretKey )
5757 if err != nil {
5858 return nil , "" , err
5959 }
6060
6161 return sqsClient , region , err
6262}
6363
64- func NewSQSClient (httpClient * http.Client , region string , endpoint string , accessKey string , secretKey string ) (* sqs.Client , error ) {
64+ func NewSQSClient (ctx context. Context , httpClient * http.Client , region string , endpoint string , accessKey string , secretKey string ) (* sqs.Client , error ) {
6565 customEndpoint := strings .ReplaceAll (endpoint , "{region}" , region )
6666 customConfig , err := config .LoadDefaultConfig (
67- context . TODO () ,
67+ ctx ,
6868 config .WithRegion (region ),
6969 config .WithBaseEndpoint (customEndpoint ),
7070 config .WithHTTPClient (httpClient ),
@@ -147,20 +147,20 @@ func splitNATSJWTAndSeed(credentials string) (string, string, error) {
147147const SQSFIFOQueueNameSuffix = ".fifo"
148148
149149var SQSAttributesToResourceMap = map [string ]string {
150- string (awsType .QueueAttributeNameMaximumMessageSize ): "message_max_size" ,
151- string (awsType .QueueAttributeNameMessageRetentionPeriod ): "message_max_age" ,
152- string (awsType .QueueAttributeNameFifoQueue ): "fifo_queue" ,
153- string (awsType .QueueAttributeNameContentBasedDeduplication ): "content_based_deduplication" ,
154- string (awsType .QueueAttributeNameReceiveMessageWaitTimeSeconds ): "receive_wait_time_seconds" ,
155- string (awsType .QueueAttributeNameVisibilityTimeout ): "visibility_timeout_seconds" ,
150+ string (awstype .QueueAttributeNameMaximumMessageSize ): "message_max_size" ,
151+ string (awstype .QueueAttributeNameMessageRetentionPeriod ): "message_max_age" ,
152+ string (awstype .QueueAttributeNameFifoQueue ): "fifo_queue" ,
153+ string (awstype .QueueAttributeNameContentBasedDeduplication ): "content_based_deduplication" ,
154+ string (awstype .QueueAttributeNameReceiveMessageWaitTimeSeconds ): "receive_wait_time_seconds" ,
155+ string (awstype .QueueAttributeNameVisibilityTimeout ): "visibility_timeout_seconds" ,
156156}
157157
158158// Returns all managed SQS attribute names
159- func getSQSAttributeNames () []awsType .QueueAttributeName {
160- attributeNames := make ([]awsType .QueueAttributeName , 0 , len (SQSAttributesToResourceMap ))
159+ func getSQSAttributeNames () []awstype .QueueAttributeName {
160+ attributeNames := make ([]awstype .QueueAttributeName , 0 , len (SQSAttributesToResourceMap ))
161161
162162 for attribute := range SQSAttributesToResourceMap {
163- attributeNames = append (attributeNames , awsType .QueueAttributeName (attribute ))
163+ attributeNames = append (attributeNames , awstype .QueueAttributeName (attribute ))
164164 }
165165
166166 return attributeNames
0 commit comments