@@ -15,8 +15,10 @@ import (
15
15
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
16
16
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
17
17
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
18
+ "github.com/hashicorp/terraform-provider-aws/internal/conns"
18
19
"github.com/hashicorp/terraform-provider-aws/internal/create"
19
20
"github.com/hashicorp/terraform-provider-aws/internal/enum"
21
+ "github.com/hashicorp/terraform-provider-aws/internal/errs"
20
22
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
21
23
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
22
24
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
@@ -28,10 +30,6 @@ const (
28
30
patchBaselineIDRegexPattern = `pb-[0-9a-f]{17}`
29
31
)
30
32
31
- type ssmClient interface {
32
- SSMClient () * ssm.Client
33
- }
34
-
35
33
// @SDKResource("aws_ssm_default_patch_baseline")
36
34
func ResourceDefaultPatchBaseline () * schema.Resource {
37
35
return & schema.Resource {
@@ -44,7 +42,7 @@ func ResourceDefaultPatchBaseline() *schema.Resource {
44
42
id := d .Id ()
45
43
46
44
if isPatchBaselineID (id ) || isPatchBaselineARN (id ) {
47
- conn := meta .(ssmClient ).SSMClient ()
45
+ conn := meta .(* conns. AWSClient ).SSMClient (ctx )
48
46
49
47
patchbaseline , err := findPatchBaselineByID (ctx , conn , id )
50
48
if err != nil {
@@ -169,7 +167,7 @@ const (
169
167
)
170
168
171
169
func resourceDefaultPatchBaselineCreate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
172
- conn := meta .(ssmClient ).SSMClient ()
170
+ conn := meta .(* conns. AWSClient ).SSMClient (ctx )
173
171
174
172
baselineID := d .Get ("baseline_id" ).(string )
175
173
@@ -199,7 +197,7 @@ func resourceDefaultPatchBaselineCreate(ctx context.Context, d *schema.ResourceD
199
197
}
200
198
201
199
func resourceDefaultPatchBaselineRead (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
202
- conn := meta .(ssmClient ).SSMClient ()
200
+ conn := meta .(* conns. AWSClient ).SSMClient (ctx )
203
201
204
202
out , err := FindDefaultPatchBaseline (ctx , conn , types .OperatingSystem (d .Id ()))
205
203
if ! d .IsNewResource () && tfresource .NotFound (err ) {
@@ -245,7 +243,7 @@ func ownerIsSelfFilter() types.PatchOrchestratorFilter { //nolint:unused // This
245
243
}
246
244
247
245
func resourceDefaultPatchBaselineDelete (ctx context.Context , d * schema.ResourceData , meta any ) (diags diag.Diagnostics ) {
248
- return defaultPatchBaselineRestoreOSDefault (ctx , meta .(ssmClient ).SSMClient (), types .OperatingSystem (d .Id ()))
246
+ return defaultPatchBaselineRestoreOSDefault (ctx , meta .(* conns. AWSClient ).SSMClient (ctx ), types .OperatingSystem (d .Id ()))
249
247
}
250
248
251
249
func defaultPatchBaselineRestoreOSDefault (ctx context.Context , conn * ssm.Client , os types.OperatingSystem ) (diags diag.Diagnostics ) {
@@ -280,15 +278,15 @@ func FindDefaultPatchBaseline(ctx context.Context, conn *ssm.Client, os types.Op
280
278
OperatingSystem : os ,
281
279
}
282
280
out , err := conn .GetDefaultPatchBaseline (ctx , in )
283
- if err != nil {
284
- var nfe * types.DoesNotExistException
285
- if errors .As (err , & nfe ) {
286
- return nil , & retry.NotFoundError {
287
- LastError : err ,
288
- LastRequest : in ,
289
- }
281
+
282
+ if errs.IsA [* types.DoesNotExistException ](err ) {
283
+ return nil , & retry.NotFoundError {
284
+ LastError : err ,
285
+ LastRequest : in ,
290
286
}
287
+ }
291
288
289
+ if err != nil {
292
290
return nil , err
293
291
}
294
292
@@ -304,15 +302,15 @@ func findPatchBaselineByID(ctx context.Context, conn *ssm.Client, id string) (*s
304
302
BaselineId : aws .String (id ),
305
303
}
306
304
out , err := conn .GetPatchBaseline (ctx , in )
307
- if err != nil {
308
- var nfe * types.DoesNotExistException
309
- if errors .As (err , & nfe ) {
310
- return nil , & retry.NotFoundError {
311
- LastError : err ,
312
- LastRequest : in ,
313
- }
305
+
306
+ if errs.IsA [* types.DoesNotExistException ](err ) {
307
+ return nil , & retry.NotFoundError {
308
+ LastError : err ,
309
+ LastRequest : in ,
314
310
}
311
+ }
315
312
313
+ if err != nil {
316
314
return nil , err
317
315
}
318
316
0 commit comments