@@ -4,16 +4,16 @@ import (
4
4
"context"
5
5
"errors"
6
6
"fmt"
7
+ "log"
7
8
"net/http"
8
9
"regexp"
9
10
"strings"
10
11
"time"
11
12
12
13
"github.com/aws/aws-sdk-go-v2/config"
13
- awsType "github.com/aws/aws-sdk-go-v2/service/sqs/types"
14
-
15
14
"github.com/aws/aws-sdk-go-v2/credentials"
16
15
"github.com/aws/aws-sdk-go-v2/service/sqs"
16
+ awstype "github.com/aws/aws-sdk-go-v2/service/sqs/types"
17
17
smithylogging "github.com/aws/smithy-go/logging"
18
18
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
19
19
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
@@ -39,11 +39,11 @@ type httpDebugLogger struct{}
39
39
40
40
func (h * httpDebugLogger ) Logf (classification smithylogging.Classification , format string , v ... interface {}) {
41
41
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 ... ))
43
43
}
44
44
}
45
45
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 ) {
47
47
region , err := meta .ExtractRegion (d , m )
48
48
if err != nil {
49
49
return nil , "" , err
@@ -53,18 +53,18 @@ func SQSClientWithRegion(d *schema.ResourceData, m interface{}) (*sqs.Client, sc
53
53
accessKey := d .Get ("access_key" ).(string )
54
54
secretKey := d .Get ("secret_key" ).(string )
55
55
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 )
57
57
if err != nil {
58
58
return nil , "" , err
59
59
}
60
60
61
61
return sqsClient , region , err
62
62
}
63
63
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 ) {
65
65
customEndpoint := strings .ReplaceAll (endpoint , "{region}" , region )
66
66
customConfig , err := config .LoadDefaultConfig (
67
- context . TODO () ,
67
+ ctx ,
68
68
config .WithRegion (region ),
69
69
config .WithBaseEndpoint (customEndpoint ),
70
70
config .WithHTTPClient (httpClient ),
@@ -147,20 +147,20 @@ func splitNATSJWTAndSeed(credentials string) (string, string, error) {
147
147
const SQSFIFOQueueNameSuffix = ".fifo"
148
148
149
149
var 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" ,
156
156
}
157
157
158
158
// 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 ))
161
161
162
162
for attribute := range SQSAttributesToResourceMap {
163
- attributeNames = append (attributeNames , awsType .QueueAttributeName (attribute ))
163
+ attributeNames = append (attributeNames , awstype .QueueAttributeName (attribute ))
164
164
}
165
165
166
166
return attributeNames
0 commit comments