Skip to content

Commit 77957c2

Browse files
authored
Merge pull request #41812 from hashicorp/td-modernize-go-sns
sns: Modernize Go code
2 parents b4486ff + 182d5f7 commit 77957c2

8 files changed

+43
-42
lines changed

.github/workflows/modern_go.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ jobs:
7777
# Services
7878
- run: make TEST=./internal/service/ec2 modern-check
7979
- run: make TEST=./internal/service/mq modern-check
80+
- run: make TEST=./internal/service/sns modern-check
8081
- run: make TEST=./internal/service/wafregional modern-check
8182
- run: make TEST=./internal/service/wafv2 modern-check

internal/service/sns/platform_application.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func resourcePlatformApplication() *schema.Resource {
121121
}
122122
}
123123

124-
func resourcePlatformApplicationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
124+
func resourcePlatformApplicationCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
125125
var diags diag.Diagnostics
126126
conn := meta.(*conns.AWSClient).SNSClient(ctx)
127127

@@ -137,7 +137,7 @@ func resourcePlatformApplicationCreate(ctx context.Context, d *schema.ResourceDa
137137
Platform: aws.String(d.Get("platform").(string)),
138138
}
139139

140-
outputRaw, err := tfresource.RetryWhenIsAErrorMessageContains[*types.InvalidParameterException](ctx, propagationTimeout, func() (interface{}, error) {
140+
outputRaw, err := tfresource.RetryWhenIsAErrorMessageContains[*types.InvalidParameterException](ctx, propagationTimeout, func() (any, error) {
141141
return conn.CreatePlatformApplication(ctx, input)
142142
}, "is not a valid role to allow SNS to write to Cloudwatch Logs")
143143

@@ -150,7 +150,7 @@ func resourcePlatformApplicationCreate(ctx context.Context, d *schema.ResourceDa
150150
return append(diags, resourcePlatformApplicationRead(ctx, d, meta)...)
151151
}
152152

153-
func resourcePlatformApplicationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
153+
func resourcePlatformApplicationRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
154154
var diags diag.Diagnostics
155155
conn := meta.(*conns.AWSClient).SNSClient(ctx)
156156

@@ -187,7 +187,7 @@ func resourcePlatformApplicationRead(ctx context.Context, d *schema.ResourceData
187187
return diags
188188
}
189189

190-
func resourcePlatformApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
190+
func resourcePlatformApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
191191
var diags diag.Diagnostics
192192
conn := meta.(*conns.AWSClient).SNSClient(ctx)
193193

@@ -229,7 +229,7 @@ func resourcePlatformApplicationUpdate(ctx context.Context, d *schema.ResourceDa
229229
PlatformApplicationArn: aws.String(d.Id()),
230230
}
231231

232-
_, err = tfresource.RetryWhenIsAErrorMessageContains[*types.InvalidParameterException](ctx, propagationTimeout, func() (interface{}, error) {
232+
_, err = tfresource.RetryWhenIsAErrorMessageContains[*types.InvalidParameterException](ctx, propagationTimeout, func() (any, error) {
233233
return conn.SetPlatformApplicationAttributes(ctx, input)
234234
}, "is not a valid role to allow SNS to write to Cloudwatch Logs")
235235

@@ -240,7 +240,7 @@ func resourcePlatformApplicationUpdate(ctx context.Context, d *schema.ResourceDa
240240
return append(diags, resourcePlatformApplicationRead(ctx, d, meta)...)
241241
}
242242

243-
func resourcePlatformApplicationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
243+
func resourcePlatformApplicationDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
244244
var diags diag.Diagnostics
245245
conn := meta.(*conns.AWSClient).SNSClient(ctx)
246246

@@ -310,7 +310,7 @@ func parsePlatformApplicationResourceID(input string) (arnS, name, platform stri
310310
return
311311
}
312312

313-
func isChangeSha256Removal(oldRaw, newRaw interface{}) bool {
313+
func isChangeSha256Removal(oldRaw, newRaw any) bool {
314314
old, ok := oldRaw.(string)
315315
if !ok {
316316
return false

internal/service/sns/sms_preferences.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import (
1717
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
1818
)
1919

20-
func validateMonthlySpend(v interface{}, k string) (ws []string, errors []error) {
20+
func validateMonthlySpend(v any, k string) (ws []string, errors []error) {
2121
vInt := v.(int)
2222
if vInt < 0 {
2323
errors = append(errors, fmt.Errorf("setting SMS preferences: monthly spend limit value [%d] must be >= 0", vInt))
2424
}
2525
return
2626
}
2727

28-
func validateDeliverySamplingRate(v interface{}, k string) (ws []string, errors []error) {
28+
func validateDeliverySamplingRate(v any, k string) (ws []string, errors []error) {
2929
vInt, _ := strconv.Atoi(v.(string))
3030
if vInt < 0 || vInt > 100 {
3131
errors = append(errors, fmt.Errorf("setting SMS preferences: default percentage of success to sample value [%d] must be between 0 and 100", vInt))
@@ -135,7 +135,7 @@ func resourceSMSPreferences() *schema.Resource {
135135
}
136136
}
137137

138-
func resourceSMSPreferencesSet(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
138+
func resourceSMSPreferencesSet(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
139139
var diags diag.Diagnostics
140140
conn := meta.(*conns.AWSClient).SNSClient(ctx)
141141

@@ -159,7 +159,7 @@ func resourceSMSPreferencesSet(ctx context.Context, d *schema.ResourceData, meta
159159
return diags
160160
}
161161

162-
func resourceSMSPreferencesGet(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
162+
func resourceSMSPreferencesGet(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
163163
var diags diag.Diagnostics
164164
conn := meta.(*conns.AWSClient).SNSClient(ctx)
165165

@@ -172,7 +172,7 @@ func resourceSMSPreferencesGet(ctx context.Context, d *schema.ResourceData, meta
172172
return sdkdiag.AppendFromErr(diags, SMSPreferencesAttributeMap.APIAttributesToResourceData(output.Attributes, d))
173173
}
174174

175-
func resourceSMSPreferencesDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
175+
func resourceSMSPreferencesDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
176176
var diags diag.Diagnostics
177177
conn := meta.(*conns.AWSClient).SNSClient(ctx)
178178

internal/service/sns/topic.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var (
5757
ValidateFunc: validation.StringIsJSON,
5858
DiffSuppressFunc: verify.SuppressEquivalentJSONWithEmptyDiffs,
5959
DiffSuppressOnRefresh: true,
60-
StateFunc: func(v interface{}) string {
60+
StateFunc: func(v any) string {
6161
json, _ := structure.NormalizeJsonString(v)
6262
return json
6363
},
@@ -81,7 +81,7 @@ var (
8181
ValidateFunc: validation.StringIsJSON,
8282
DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs,
8383
DiffSuppressOnRefresh: true,
84-
StateFunc: func(v interface{}) string {
84+
StateFunc: func(v any) string {
8585
json, _ := structure.NormalizeJsonString(v)
8686
return json
8787
},
@@ -170,7 +170,7 @@ var (
170170
ValidateFunc: validation.StringIsJSON,
171171
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
172172
DiffSuppressOnRefresh: true,
173-
StateFunc: func(v interface{}) string {
173+
StateFunc: func(v any) string {
174174
json, _ := structure.NormalizeJsonString(v)
175175
return json
176176
},
@@ -257,7 +257,7 @@ func resourceTopic() *schema.Resource {
257257
}
258258
}
259259

260-
func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
260+
func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
261261
var diags diag.Diagnostics
262262
conn := meta.(*conns.AWSClient).SNSClient(ctx)
263263

@@ -299,7 +299,7 @@ func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta inter
299299
// Retry for eventual consistency; if ABAC is in use, this takes some time
300300
// usually about 10s, presumably for tags really to be there, and we get a
301301
// permissions error.
302-
_, err = tfresource.RetryWhenIsAErrorMessageContains[*types.AuthorizationErrorException](ctx, propagationTimeout, func() (interface{}, error) {
302+
_, err = tfresource.RetryWhenIsAErrorMessageContains[*types.AuthorizationErrorException](ctx, propagationTimeout, func() (any, error) {
303303
return nil, putTopicAttributes(ctx, conn, d.Id(), attributes)
304304
}, "no identity-based policy allows")
305305

@@ -312,7 +312,7 @@ func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta inter
312312
err := createTags(ctx, conn, d.Id(), tags)
313313

314314
// If default tags only, continue. Otherwise, error.
315-
if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) {
315+
if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]any)) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) {
316316
return append(diags, resourceTopicRead(ctx, d, meta)...)
317317
}
318318

@@ -360,7 +360,7 @@ func resourceTopicRead(ctx context.Context, d *schema.ResourceData, meta any) di
360360
return diags
361361
}
362362

363-
func resourceTopicUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
363+
func resourceTopicUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
364364
var diags diag.Diagnostics
365365
conn := meta.(*conns.AWSClient).SNSClient(ctx)
366366

@@ -379,7 +379,7 @@ func resourceTopicUpdate(ctx context.Context, d *schema.ResourceData, meta inter
379379
return append(diags, resourceTopicRead(ctx, d, meta)...)
380380
}
381381

382-
func resourceTopicDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
382+
func resourceTopicDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
383383
var diags diag.Diagnostics
384384
conn := meta.(*conns.AWSClient).SNSClient(ctx)
385385

@@ -399,7 +399,7 @@ func resourceTopicDelete(ctx context.Context, d *schema.ResourceData, meta inter
399399
return diags
400400
}
401401

402-
func resourceTopicCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
402+
func resourceTopicCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta any) error {
403403
fifoTopic := diff.Get("fifo_topic").(bool)
404404
archivePolicy := diff.Get("archive_policy").(string)
405405
contentBasedDeduplication := diff.Get("content_based_deduplication").(bool)
@@ -459,7 +459,7 @@ func putTopicAttribute(ctx context.Context, conn *sns.Client, arn string, name,
459459
TopicArn: aws.String(arn),
460460
}
461461

462-
_, err := tfresource.RetryWhenIsA[*types.InvalidParameterException](ctx, timeout, func() (interface{}, error) {
462+
_, err := tfresource.RetryWhenIsA[*types.InvalidParameterException](ctx, timeout, func() (any, error) {
463463
return conn.SetTopicAttributes(ctx, input)
464464
})
465465

internal/service/sns/topic_data_protection_policy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func resourceTopicDataProtectionPolicy() *schema.Resource {
4848
ValidateFunc: validation.StringIsJSON,
4949
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
5050
DiffSuppressOnRefresh: true,
51-
StateFunc: func(v interface{}) string {
51+
StateFunc: func(v any) string {
5252
json, _ := structure.NormalizeJsonString(v)
5353
return json
5454
},
@@ -57,7 +57,7 @@ func resourceTopicDataProtectionPolicy() *schema.Resource {
5757
}
5858
}
5959

60-
func resourceTopicDataProtectionPolicyUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
60+
func resourceTopicDataProtectionPolicyUpsert(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
6161
var diags diag.Diagnostics
6262
conn := meta.(*conns.AWSClient).SNSClient(ctx)
6363

@@ -85,7 +85,7 @@ func resourceTopicDataProtectionPolicyUpsert(ctx context.Context, d *schema.Reso
8585
return append(diags, resourceTopicDataProtectionPolicyRead(ctx, d, meta)...)
8686
}
8787

88-
func resourceTopicDataProtectionPolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
88+
func resourceTopicDataProtectionPolicyRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
8989
var diags diag.Diagnostics
9090
conn := meta.(*conns.AWSClient).SNSClient(ctx)
9191

@@ -107,7 +107,7 @@ func resourceTopicDataProtectionPolicyRead(ctx context.Context, d *schema.Resour
107107
return diags
108108
}
109109

110-
func resourceTopicDataProtectionPolicyDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
110+
func resourceTopicDataProtectionPolicyDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
111111
var diags diag.Diagnostics
112112
conn := meta.(*conns.AWSClient).SNSClient(ctx)
113113

internal/service/sns/topic_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func dataSourceTopic() *schema.Resource {
4141
}
4242
}
4343

44-
func dataSourceTopicRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
44+
func dataSourceTopicRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
4545
var diags diag.Diagnostics
4646
conn := meta.(*conns.AWSClient).SNSClient(ctx)
4747

internal/service/sns/topic_policy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func resourceTopicPolicy() *schema.Resource {
5151
ValidateFunc: validation.StringIsJSON,
5252
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
5353
DiffSuppressOnRefresh: true,
54-
StateFunc: func(v interface{}) string {
54+
StateFunc: func(v any) string {
5555
json, _ := structure.NormalizeJsonString(v)
5656
return json
5757
},
@@ -60,7 +60,7 @@ func resourceTopicPolicy() *schema.Resource {
6060
}
6161
}
6262

63-
func resourceTopicPolicyUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
63+
func resourceTopicPolicyUpsert(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
6464
var diags diag.Diagnostics
6565
conn := meta.(*conns.AWSClient).SNSClient(ctx)
6666

@@ -83,7 +83,7 @@ func resourceTopicPolicyUpsert(ctx context.Context, d *schema.ResourceData, meta
8383
return append(diags, resourceTopicPolicyRead(ctx, d, meta)...)
8484
}
8585

86-
func resourceTopicPolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
86+
func resourceTopicPolicyRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
8787
var diags diag.Diagnostics
8888
conn := meta.(*conns.AWSClient).SNSClient(ctx)
8989

@@ -122,7 +122,7 @@ func resourceTopicPolicyRead(ctx context.Context, d *schema.ResourceData, meta i
122122
return diags
123123
}
124124

125-
func resourceTopicPolicyDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
125+
func resourceTopicPolicyDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
126126
var diags diag.Diagnostics
127127
conn := meta.(*conns.AWSClient).SNSClient(ctx)
128128

internal/service/sns/topic_subscription.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var (
5252
ValidateFunc: validation.StringIsJSON,
5353
DiffSuppressFunc: SuppressEquivalentTopicSubscriptionDeliveryPolicy,
5454
DiffSuppressOnRefresh: true,
55-
StateFunc: func(v interface{}) string {
55+
StateFunc: func(v any) string {
5656
json, _ := structure.NormalizeJsonString(v)
5757
return json
5858
},
@@ -73,7 +73,7 @@ var (
7373
ValidateFunc: validation.StringIsJSON,
7474
DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs,
7575
DiffSuppressOnRefresh: true,
76-
StateFunc: func(v interface{}) string {
76+
StateFunc: func(v any) string {
7777
json, _ := structure.NormalizeJsonString(v)
7878
return json
7979
},
@@ -109,7 +109,7 @@ var (
109109
ValidateFunc: validation.StringIsJSON,
110110
DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs,
111111
DiffSuppressOnRefresh: true,
112-
StateFunc: func(v interface{}) string {
112+
StateFunc: func(v any) string {
113113
json, _ := structure.NormalizeJsonString(v)
114114
return json
115115
},
@@ -120,7 +120,7 @@ var (
120120
ValidateFunc: validation.StringIsJSON,
121121
DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs,
122122
DiffSuppressOnRefresh: true,
123-
StateFunc: func(v interface{}) string {
123+
StateFunc: func(v any) string {
124124
json, _ := structure.NormalizeJsonString(v)
125125
return json
126126
},
@@ -174,7 +174,7 @@ func resourceTopicSubscription() *schema.Resource {
174174
}
175175
}
176176

177-
func resourceTopicSubscriptionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
177+
func resourceTopicSubscriptionCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
178178
var diags diag.Diagnostics
179179
conn := meta.(*conns.AWSClient).SNSClient(ctx)
180180

@@ -229,11 +229,11 @@ func resourceTopicSubscriptionCreate(ctx context.Context, d *schema.ResourceData
229229
return append(diags, resourceTopicSubscriptionRead(ctx, d, meta)...)
230230
}
231231

232-
func resourceTopicSubscriptionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
232+
func resourceTopicSubscriptionRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
233233
var diags diag.Diagnostics
234234
conn := meta.(*conns.AWSClient).SNSClient(ctx)
235235

236-
outputRaw, err := tfresource.RetryWhenNewResourceNotFound(ctx, subscriptionCreateTimeout, func() (interface{}, error) {
236+
outputRaw, err := tfresource.RetryWhenNewResourceNotFound(ctx, subscriptionCreateTimeout, func() (any, error) {
237237
return findSubscriptionAttributesByARN(ctx, conn, d.Id())
238238
}, d.IsNewResource())
239239

@@ -252,7 +252,7 @@ func resourceTopicSubscriptionRead(ctx context.Context, d *schema.ResourceData,
252252
return sdkdiag.AppendFromErr(diags, subscriptionAttributeMap.APIAttributesToResourceData(attributes, d))
253253
}
254254

255-
func resourceTopicSubscriptionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
255+
func resourceTopicSubscriptionUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
256256
var diags diag.Diagnostics
257257
conn := meta.(*conns.AWSClient).SNSClient(ctx)
258258

@@ -270,7 +270,7 @@ func resourceTopicSubscriptionUpdate(ctx context.Context, d *schema.ResourceData
270270
return append(diags, resourceTopicSubscriptionRead(ctx, d, meta)...)
271271
}
272272

273-
func resourceTopicSubscriptionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
273+
func resourceTopicSubscriptionDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
274274
var diags diag.Diagnostics
275275
conn := meta.(*conns.AWSClient).SNSClient(ctx)
276276

@@ -384,7 +384,7 @@ func findSubscriptionAttributesByARN(ctx context.Context, conn *sns.Client, arn
384384
}
385385

386386
func statusSubscriptionPendingConfirmation(ctx context.Context, conn *sns.Client, arn string) retry.StateRefreshFunc {
387-
return func() (interface{}, string, error) {
387+
return func() (any, string, error) {
388388
output, err := findSubscriptionAttributesByARN(ctx, conn, arn)
389389

390390
if tfresource.NotFound(err) {
@@ -543,7 +543,7 @@ func normalizeTopicSubscriptionDeliveryPolicy(policy string) ([]byte, error) {
543543
return b.Bytes(), nil
544544
}
545545

546-
func resourceTopicSubscriptionCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
546+
func resourceTopicSubscriptionCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, _ any) error {
547547
hasPolicy := diff.Get("filter_policy").(string) != ""
548548
hasScope := !diff.GetRawConfig().GetAttr("filter_policy_scope").IsNull()
549549
hadScope := diff.Get("filter_policy_scope").(string) != ""

0 commit comments

Comments
 (0)