@@ -10,7 +10,6 @@ import (
10
10
"iter"
11
11
"log"
12
12
"net/url"
13
- "reflect"
14
13
"strings"
15
14
"time"
16
15
@@ -43,7 +42,7 @@ import (
43
42
"github.com/hashicorp/terraform-provider-aws/internal/retry"
44
43
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
45
44
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
46
- itypes "github.com/hashicorp/terraform-provider-aws/internal/types"
45
+ inttypes "github.com/hashicorp/terraform-provider-aws/internal/types"
47
46
"github.com/hashicorp/terraform-provider-aws/internal/verify"
48
47
"github.com/hashicorp/terraform-provider-aws/names"
49
48
)
@@ -214,7 +213,7 @@ func resourceRole() *schema.Resource {
214
213
}
215
214
216
215
// @SDKListResource("aws_iam_role")
217
- func instanceResourceAsListResource () itypes .ListResourceForSDK {
216
+ func instanceResourceAsListResource () inttypes .ListResourceForSDK {
218
217
l := roleListResource {}
219
218
l .SetResourceSchema (resourceRole ())
220
219
@@ -231,7 +230,7 @@ func resourceRoleCreate(ctx context.Context, d *schema.ResourceData, meta any) d
231
230
}
232
231
233
232
name := create .Name (d .Get (names .AttrName ).(string ), d .Get (names .AttrNamePrefix ).(string ))
234
- input := & iam.CreateRoleInput {
233
+ input := iam.CreateRoleInput {
235
234
AssumeRolePolicyDocument : aws .String (assumeRolePolicy ),
236
235
Path : aws .String (d .Get (names .AttrPath ).(string )),
237
236
RoleName : aws .String (name ),
@@ -250,14 +249,14 @@ func resourceRoleCreate(ctx context.Context, d *schema.ResourceData, meta any) d
250
249
input .PermissionsBoundary = aws .String (v .(string ))
251
250
}
252
251
253
- output , err := retryCreateRole (ctx , conn , input )
252
+ output , err := retryCreateRole (ctx , conn , & input )
254
253
255
254
// Some partitions (e.g. ISO) may not support tag-on-create.
256
255
partition := meta .(* conns.AWSClient ).Partition (ctx )
257
256
if input .Tags != nil && errs .IsUnsupportedOperationInPartitionError (partition , err ) {
258
257
input .Tags = nil
259
258
260
- output , err = retryCreateRole (ctx , conn , input )
259
+ output , err = retryCreateRole (ctx , conn , & input )
261
260
}
262
261
263
262
if err != nil {
@@ -369,14 +368,14 @@ func resourceRoleUpdate(ctx context.Context, d *schema.ResourceData, meta any) d
369
368
return sdkdiag .AppendErrorf (diags , "assume_role_policy (%s) is invalid JSON: %s" , assumeRolePolicy , err )
370
369
}
371
370
372
- input := & iam.UpdateAssumeRolePolicyInput {
371
+ input := iam.UpdateAssumeRolePolicyInput {
373
372
RoleName : aws .String (d .Id ()),
374
373
PolicyDocument : aws .String (assumeRolePolicy ),
375
374
}
376
375
377
376
_ , err = tfresource .RetryWhen (ctx , propagationTimeout ,
378
377
func (ctx context.Context ) (any , error ) {
379
- return conn .UpdateAssumeRolePolicy (ctx , input )
378
+ return conn .UpdateAssumeRolePolicy (ctx , & input )
380
379
},
381
380
func (err error ) (bool , error ) {
382
381
if errs .IsAErrorMessageContains [* awstypes.MalformedPolicyDocumentException ](err , "Invalid principal in policy" ) {
@@ -393,25 +392,25 @@ func resourceRoleUpdate(ctx context.Context, d *schema.ResourceData, meta any) d
393
392
}
394
393
395
394
if d .HasChange (names .AttrDescription ) {
396
- input := & iam.UpdateRoleDescriptionInput {
397
- RoleName : aws .String (d .Id ()),
395
+ input := iam.UpdateRoleDescriptionInput {
398
396
Description : aws .String (d .Get (names .AttrDescription ).(string )),
397
+ RoleName : aws .String (d .Id ()),
399
398
}
400
399
401
- _ , err := conn .UpdateRoleDescription (ctx , input )
400
+ _ , err := conn .UpdateRoleDescription (ctx , & input )
402
401
403
402
if err != nil {
404
403
return sdkdiag .AppendErrorf (diags , "updating IAM Role (%s) description: %s" , d .Id (), err )
405
404
}
406
405
}
407
406
408
407
if d .HasChange ("max_session_duration" ) {
409
- input := & iam.UpdateRoleInput {
410
- RoleName : aws .String (d .Id ()),
408
+ input := iam.UpdateRoleInput {
411
409
MaxSessionDuration : aws .Int32 (int32 (d .Get ("max_session_duration" ).(int ))),
410
+ RoleName : aws .String (d .Id ()),
412
411
}
413
412
414
- _ , err := conn .UpdateRole (ctx , input )
413
+ _ , err := conn .UpdateRole (ctx , & input )
415
414
416
415
if err != nil {
417
416
return sdkdiag .AppendErrorf (diags , "updating IAM Role (%s) MaxSessionDuration: %s" , d .Id (), err )
@@ -421,22 +420,22 @@ func resourceRoleUpdate(ctx context.Context, d *schema.ResourceData, meta any) d
421
420
if d .HasChange ("permissions_boundary" ) {
422
421
permissionsBoundary := d .Get ("permissions_boundary" ).(string )
423
422
if permissionsBoundary != "" {
424
- input := & iam.PutRolePermissionsBoundaryInput {
423
+ input := iam.PutRolePermissionsBoundaryInput {
425
424
PermissionsBoundary : aws .String (permissionsBoundary ),
426
425
RoleName : aws .String (d .Id ()),
427
426
}
428
427
429
- _ , err := conn .PutRolePermissionsBoundary (ctx , input )
428
+ _ , err := conn .PutRolePermissionsBoundary (ctx , & input )
430
429
431
430
if err != nil {
432
431
return sdkdiag .AppendErrorf (diags , "updating IAM Role (%s) permissions boundary: %s" , d .Id (), err )
433
432
}
434
433
} else {
435
- input := & iam.DeleteRolePermissionsBoundaryInput {
434
+ input := iam.DeleteRolePermissionsBoundaryInput {
436
435
RoleName : aws .String (d .Id ()),
437
436
}
438
437
439
- _ , err := conn .DeleteRolePermissionsBoundary (ctx , input )
438
+ _ , err := conn .DeleteRolePermissionsBoundary (ctx , & input )
440
439
441
440
if err != nil {
442
441
return sdkdiag .AppendErrorf (diags , "deleting IAM Role (%s) permissions boundary: %s" , d .Id (), err )
@@ -558,12 +557,12 @@ func deleteRole(ctx context.Context, conn *iam.Client, roleName string, forceDet
558
557
}
559
558
}
560
559
561
- input := & iam.DeleteRoleInput {
560
+ input := iam.DeleteRoleInput {
562
561
RoleName : aws .String (roleName ),
563
562
}
564
563
565
564
_ , err := tfresource .RetryWhenIsA [any , * awstypes.DeleteConflictException ](ctx , propagationTimeout , func (ctx context.Context ) (any , error ) {
566
- return conn .DeleteRole (ctx , input )
565
+ return conn .DeleteRole (ctx , & input )
567
566
})
568
567
569
568
if errs.IsA [* awstypes.NoSuchEntityException ](err ) {
@@ -588,12 +587,12 @@ func deleteRoleInstanceProfiles(ctx context.Context, conn *iam.Client, roleName
588
587
589
588
for _ , instanceProfile := range instanceProfiles {
590
589
instanceProfileName := aws .ToString (instanceProfile .InstanceProfileName )
591
- input := & iam.RemoveRoleFromInstanceProfileInput {
590
+ input := iam.RemoveRoleFromInstanceProfileInput {
592
591
InstanceProfileName : aws .String (instanceProfileName ),
593
592
RoleName : aws .String (roleName ),
594
593
}
595
594
596
- _ , err := conn .RemoveRoleFromInstanceProfile (ctx , input )
595
+ _ , err := conn .RemoveRoleFromInstanceProfile (ctx , & input )
597
596
598
597
if errs.IsA [* awstypes.NoSuchEntityException ](err ) {
599
598
continue
@@ -637,11 +636,11 @@ func retryCreateRole(ctx context.Context, conn *iam.Client, input *iam.CreateRol
637
636
}
638
637
639
638
func findRoleByName (ctx context.Context , conn * iam.Client , name string ) (* awstypes.Role , error ) {
640
- input := & iam.GetRoleInput {
639
+ input := iam.GetRoleInput {
641
640
RoleName : aws .String (name ),
642
641
}
643
642
644
- return findRole (ctx , conn , input )
643
+ return findRole (ctx , conn , & input )
645
644
}
646
645
647
646
func findRole (ctx context.Context , conn * iam.Client , input * iam.GetRoleInput ) (* awstypes.Role , error ) {
@@ -767,12 +766,12 @@ func resourceRoleFlatten(ctx context.Context, role *awstypes.Role, d *schema.Res
767
766
}
768
767
769
768
func findRoleAttachedPolicies (ctx context.Context , conn * iam.Client , roleName string ) ([]string , error ) {
770
- input := & iam.ListAttachedRolePoliciesInput {
769
+ input := iam.ListAttachedRolePoliciesInput {
771
770
RoleName : aws .String (roleName ),
772
771
}
773
772
var output []string
774
773
775
- pages := iam .NewListAttachedRolePoliciesPaginator (conn , input )
774
+ pages := iam .NewListAttachedRolePoliciesPaginator (conn , & input )
776
775
for pages .HasMorePages () {
777
776
page , err := pages .NextPage (ctx )
778
777
@@ -787,7 +786,7 @@ func findRoleAttachedPolicies(ctx context.Context, conn *iam.Client, roleName st
787
786
}
788
787
789
788
for _ , v := range page .AttachedPolicies {
790
- if ! reflect . ValueOf ( v ). IsZero () {
789
+ if p := & v ; ! inttypes . IsZero (p ) {
791
790
output = append (output , aws .ToString (v .PolicyArn ))
792
791
}
793
792
}
@@ -797,12 +796,12 @@ func findRoleAttachedPolicies(ctx context.Context, conn *iam.Client, roleName st
797
796
}
798
797
799
798
func findRolePolicyNames (ctx context.Context , conn * iam.Client , roleName string ) ([]string , error ) {
800
- input := & iam.ListRolePoliciesInput {
799
+ input := iam.ListRolePoliciesInput {
801
800
RoleName : aws .String (roleName ),
802
801
}
803
802
var output []string
804
803
805
- pages := iam .NewListRolePoliciesPaginator (conn , input )
804
+ pages := iam .NewListRolePoliciesPaginator (conn , & input )
806
805
for pages .HasMorePages () {
807
806
page , err := pages .NextPage (ctx )
808
807
@@ -830,12 +829,12 @@ func deleteRolePolicyAttachments(ctx context.Context, conn *iam.Client, roleName
830
829
var errsList []error
831
830
832
831
for _ , policyARN := range policyARNs {
833
- input := & iam.DetachRolePolicyInput {
832
+ input := iam.DetachRolePolicyInput {
834
833
PolicyArn : aws .String (policyARN ),
835
834
RoleName : aws .String (roleName ),
836
835
}
837
836
838
- _ , err := conn .DetachRolePolicy (ctx , input )
837
+ _ , err := conn .DetachRolePolicy (ctx , & input )
839
838
840
839
if errs.IsA [* awstypes.NoSuchEntityException ](err ) {
841
840
continue
@@ -857,12 +856,12 @@ func deleteRoleInlinePolicies(ctx context.Context, conn *iam.Client, roleName st
857
856
continue
858
857
}
859
858
860
- input := & iam.DeleteRolePolicyInput {
859
+ input := iam.DeleteRolePolicyInput {
861
860
PolicyName : aws .String (policyName ),
862
861
RoleName : aws .String (roleName ),
863
862
}
864
863
865
- _ , err := conn .DeleteRolePolicy (ctx , input )
864
+ _ , err := conn .DeleteRolePolicy (ctx , & input )
866
865
867
866
if errs.IsA [* awstypes.NoSuchEntityException ](err ) {
868
867
continue
@@ -997,10 +996,11 @@ func readRoleInlinePolicies(ctx context.Context, conn *iam.Client, roleName stri
997
996
var apiObjects []* iam.PutRolePolicyInput
998
997
999
998
for _ , policyName := range policyNames {
1000
- output , err := conn .GetRolePolicy (ctx , & iam.GetRolePolicyInput {
1001
- RoleName : aws .String (roleName ),
999
+ input := iam.GetRolePolicyInput {
1002
1000
PolicyName : aws .String (policyName ),
1003
- })
1001
+ RoleName : aws .String (roleName ),
1002
+ }
1003
+ output , err := conn .GetRolePolicy (ctx , & input )
1004
1004
1005
1005
if err != nil {
1006
1006
return nil , err
@@ -1017,9 +1017,9 @@ func readRoleInlinePolicies(ctx context.Context, conn *iam.Client, roleName stri
1017
1017
}
1018
1018
1019
1019
apiObject := & iam.PutRolePolicyInput {
1020
- RoleName : aws .String (roleName ),
1021
1020
PolicyDocument : aws .String (p ),
1022
1021
PolicyName : aws .String (policyName ),
1022
+ RoleName : aws .String (roleName ),
1023
1023
}
1024
1024
1025
1025
apiObjects = append (apiObjects , apiObject )
0 commit comments