diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index c3e87ec2536..2577da94100 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -116,34 +116,34 @@ func newTemplateBody(version int, kvtValues bool) *TemplateBody { switch version { case sdkV1: return &TemplateBody{ - "\n" + v1.GetTagBody, - v1.HeaderBody, - "\n" + v1.ListTagsBody, - "\n" + v1.ServiceTagsMapBody, - "\n" + v1.ServiceTagsSliceBody, - "\n" + v1.UpdateTagsBody, - "\n" + v1.WaitTagsPropagatedBody, + getTag: "\n" + v1.GetTagBody, + header: v1.HeaderBody, + listTags: "\n" + v1.ListTagsBody, + serviceTagsMap: "\n" + v1.ServiceTagsMapBody, + serviceTagsSlice: "\n" + v1.ServiceTagsSliceBody, + updateTags: "\n" + v1.UpdateTagsBody, + waitTagsPropagated: "\n" + v1.WaitTagsPropagatedBody, } case sdkV2: if kvtValues { return &TemplateBody{ - "\n" + v2.GetTagBody, - v2.HeaderBody, - "\n" + v2.ListTagsBody, - "\n" + v2.ServiceTagsValueMapBody, - "\n" + v2.ServiceTagsSliceBody, - "\n" + v2.UpdateTagsBody, - "\n" + v2.WaitTagsPropagatedBody, + getTag: "\n" + v2.GetTagBody, + header: v2.HeaderBody, + listTags: "\n" + v2.ListTagsBody, + serviceTagsMap: "\n" + v2.ServiceTagsValueMapBody, + serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, + updateTags: "\n" + v2.UpdateTagsBody, + waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, } } return &TemplateBody{ - "\n" + v2.GetTagBody, - v2.HeaderBody, - "\n" + v2.ListTagsBody, - "\n" + v2.ServiceTagsMapBody, - "\n" + v2.ServiceTagsSliceBody, - "\n" + v2.UpdateTagsBody, - "\n" + v2.WaitTagsPropagatedBody, + getTag: "\n" + v2.GetTagBody, + header: v2.HeaderBody, + listTags: "\n" + v2.ListTagsBody, + serviceTagsMap: "\n" + v2.ServiceTagsMapBody, + serviceTagsSlice: "\n" + v2.ServiceTagsSliceBody, + updateTags: "\n" + v2.UpdateTagsBody, + waitTagsPropagated: "\n" + v2.WaitTagsPropagatedBody, } default: return nil @@ -172,6 +172,7 @@ type TemplateData struct { ParentNotFoundErrCode string ParentNotFoundErrMsg string RetryCreateOnNotFound string + ServiceTagsMap bool SetTagsOutFunc string TagInCustomVal string TagInIDElem string @@ -333,6 +334,7 @@ func main() { ListTagsOutTagsElem: *listTagsOutTagsElem, ParentNotFoundErrCode: *parentNotFoundErrCode, ParentNotFoundErrMsg: *parentNotFoundErrMsg, + ServiceTagsMap: *serviceTagsMap, SetTagsOutFunc: *setTagsOutFunc, TagInCustomVal: *tagInCustomVal, TagInIDElem: *tagInIDElem, diff --git a/internal/generate/tags/templates/v1/header_body.tmpl b/internal/generate/tags/templates/v1/header_body.tmpl index 72cc432cadf..2423875c80c 100644 --- a/internal/generate/tags/templates/v1/header_body.tmpl +++ b/internal/generate/tags/templates/v1/header_body.tmpl @@ -50,4 +50,7 @@ import ( {{- if .NamesPkg }} "github.com/hashicorp/terraform-provider-aws/names" {{- end }} + {{- if and .ListTagsOpPaginated .ServiceTagsMap }} + "golang.org/x/exp/maps" + {{- end }} ) diff --git a/internal/generate/tags/templates/v1/list_tags_body.tmpl b/internal/generate/tags/templates/v1/list_tags_body.tmpl index 6f4aea7f0e9..30b63823db9 100644 --- a/internal/generate/tags/templates/v1/list_tags_body.tmpl +++ b/internal/generate/tags/templates/v1/list_tags_body.tmpl @@ -22,18 +22,26 @@ func {{ .ListTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier {{- end }} } {{- if .ListTagsOpPaginated }} - var output []*{{ .TagPackage }}.{{ .TagType }} + {{- if .ServiceTagsMap }} + output := make(map[string]*string) + {{- else }} + var output []*{{ .TagPackage }}.{{ or .TagType2 .TagType }} + {{- end }} err := conn.{{ .ListTagsOp }}PagesWithContext(ctx, input, func(page *{{ .TagPackage }}.{{ .ListTagsOp }}Output, lastPage bool) bool { if page == nil { return !lastPage } + {{ if .ServiceTagsMap }} + maps.Copy(output, page.{{ .ListTagsOutTagsElem }}) + {{- else }} for _, v := range page.{{ .ListTagsOutTagsElem }} { if v != nil { output = append(output, v) } } + {{- end }} return !lastPage }) diff --git a/internal/generate/tags/templates/v2/list_tags_body.tmpl b/internal/generate/tags/templates/v2/list_tags_body.tmpl index 43a5a50079a..f39b7fdde99 100644 --- a/internal/generate/tags/templates/v2/list_tags_body.tmpl +++ b/internal/generate/tags/templates/v2/list_tags_body.tmpl @@ -23,6 +23,40 @@ func {{ .ListTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier {{- end }} {{- end }} } +{{- if .ListTagsOpPaginated }} + var output []awstypes.{{ or .TagType2 .TagType }} + + pages := {{ .TagPackage }}.New{{ .ListTagsOp }}Paginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + {{ if and ( .ParentNotFoundErrCode ) ( .ParentNotFoundErrMsg ) }} + if tfawserr.ErrMessageContains(err, "{{ .ParentNotFoundErrCode }}", "{{ .ParentNotFoundErrMsg }}") { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + {{- else if ( .ParentNotFoundErrCode ) }} + if tfawserr.ErrCodeEquals(err, "{{ .ParentNotFoundErrCode }}") { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + {{- end }} + + if err != nil { + return tftags.New(ctx, nil), err + } + + for _, v := range page.{{ .ListTagsOutTagsElem }} { + output = append(output, v) + } + } + + return {{ .KeyValueTagsFunc }}(ctx, output{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}), nil +{{- else }} output, err := conn.{{ .ListTagsOp }}(ctx, input, optFns...) @@ -47,6 +81,7 @@ func {{ .ListTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifier } return {{ .KeyValueTagsFunc }}(ctx, output.{{ .ListTagsOutTagsElem }}{{ if .TagTypeIDElem }}, identifier{{ if .TagResTypeElem }}, resourceType{{ end }}{{ end }}), nil +{{- end }} } {{- if .IsDefaultListTags }} diff --git a/internal/service/acmpca/generate.go b/internal/service/acmpca/generate.go index 40c66b6f7b9..b3fb39cd092 100644 --- a/internal/service/acmpca/generate.go +++ b/internal/service/acmpca/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsInIDElem=CertificateAuthorityArn -ServiceTagsSlice -TagOp=TagCertificateAuthority -TagInIDElem=CertificateAuthorityArn -UntagOp=UntagCertificateAuthority -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ListTagsInIDElem=CertificateAuthorityArn -ServiceTagsSlice -TagOp=TagCertificateAuthority -TagInIDElem=CertificateAuthorityArn -UntagOp=UntagCertificateAuthority -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/acmpca/tags_gen.go b/internal/service/acmpca/tags_gen.go index df1097ebdf4..04f3ca619f3 100644 --- a/internal/service/acmpca/tags_gen.go +++ b/internal/service/acmpca/tags_gen.go @@ -23,14 +23,27 @@ func listTags(ctx context.Context, conn acmpcaiface.ACMPCAAPI, identifier string input := &acmpca.ListTagsInput{ CertificateAuthorityArn: aws.String(identifier), } + var output []*acmpca.Tag - output, err := conn.ListTagsWithContext(ctx, input) + err := conn.ListTagsPagesWithContext(ctx, input, func(page *acmpca.ListTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Tags { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags), nil + return KeyValueTags(ctx, output), nil } // ListTags lists acmpca service tags and set them in Context. diff --git a/internal/service/autoscaling/generate.go b/internal/service/autoscaling/generate.go index c29c3890830..2bd105f5a8b 100644 --- a/internal/service/autoscaling/generate.go +++ b/internal/service/autoscaling/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=DescribeTags -ListTagsInFiltIDName=auto-scaling-group -ServiceTagsSlice -TagOp=CreateOrUpdateTags -TagResTypeElem=ResourceType -TagType2=TagDescription -TagTypeAddBoolElem=PropagateAtLaunch -TagTypeIDElem=ResourceId -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInFiltIDName=auto-scaling-group -ServiceTagsSlice -TagOp=CreateOrUpdateTags -TagResTypeElem=ResourceType -TagType2=TagDescription -TagTypeAddBoolElem=PropagateAtLaunch -TagTypeIDElem=ResourceId -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeInstanceRefreshes,DescribeLoadBalancers,DescribeLoadBalancerTargetGroups,DescribeWarmPool //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/autoscaling/tags_gen.go b/internal/service/autoscaling/tags_gen.go index a3242be0421..9c8753a8fb8 100644 --- a/internal/service/autoscaling/tags_gen.go +++ b/internal/service/autoscaling/tags_gen.go @@ -64,14 +64,27 @@ func listTags(ctx context.Context, conn autoscalingiface.AutoScalingAPI, identif }, }, } + var output []*autoscaling.TagDescription - output, err := conn.DescribeTagsWithContext(ctx, input) + err := conn.DescribeTagsPagesWithContext(ctx, input, func(page *autoscaling.DescribeTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Tags { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags, identifier, resourceType), nil + return KeyValueTags(ctx, output, identifier, resourceType), nil } // ListTags lists autoscaling service tags and set them in Context. diff --git a/internal/service/backup/generate.go b/internal/service/backup/generate.go index 27f6f21aefd..22d253292fd 100644 --- a/internal/service/backup/generate.go +++ b/internal/service/backup/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsMap -UntagInTagsElem=TagKeyList -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ServiceTagsMap -UntagInTagsElem=TagKeyList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/backup/tags_gen.go b/internal/service/backup/tags_gen.go index 9b1d6b0913c..cf2ee8917f2 100644 --- a/internal/service/backup/tags_gen.go +++ b/internal/service/backup/tags_gen.go @@ -14,6 +14,7 @@ import ( tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/types/option" "github.com/hashicorp/terraform-provider-aws/names" + "golang.org/x/exp/maps" ) // listTags lists backup service tags. @@ -23,14 +24,23 @@ func listTags(ctx context.Context, conn backupiface.BackupAPI, identifier string input := &backup.ListTagsInput{ ResourceArn: aws.String(identifier), } + output := make(map[string]*string) - output, err := conn.ListTagsWithContext(ctx, input) + err := conn.ListTagsPagesWithContext(ctx, input, func(page *backup.ListTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + maps.Copy(output, page.Tags) + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags), nil + return KeyValueTags(ctx, output), nil } // ListTags lists backup service tags and set them in Context. diff --git a/internal/service/cloudhsmv2/generate.go b/internal/service/cloudhsmv2/generate.go index ee5756a0659..d2c93c8af12 100644 --- a/internal/service/cloudhsmv2/generate.go +++ b/internal/service/cloudhsmv2/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsInIDElem=ResourceId -ListTagsOutTagsElem=TagList -ServiceTagsSlice -TagInIDElem=ResourceId -TagInTagsElem=TagList -UntagInTagsElem=TagKeyList -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ListTagsInIDElem=ResourceId -ListTagsOutTagsElem=TagList -ServiceTagsSlice -TagInIDElem=ResourceId -TagInTagsElem=TagList -UntagInTagsElem=TagKeyList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/cloudhsmv2/tags_gen.go b/internal/service/cloudhsmv2/tags_gen.go index 6faa2abc71d..caa59d7d3cf 100644 --- a/internal/service/cloudhsmv2/tags_gen.go +++ b/internal/service/cloudhsmv2/tags_gen.go @@ -23,14 +23,27 @@ func listTags(ctx context.Context, conn cloudhsmv2iface.CloudHSMV2API, identifie input := &cloudhsmv2.ListTagsInput{ ResourceId: aws.String(identifier), } + var output []*cloudhsmv2.Tag - output, err := conn.ListTagsWithContext(ctx, input) + err := conn.ListTagsPagesWithContext(ctx, input, func(page *cloudhsmv2.ListTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.TagList { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.TagList), nil + return KeyValueTags(ctx, output), nil } // ListTags lists cloudhsmv2 service tags and set them in Context. diff --git a/internal/service/cloudtrail/generate.go b/internal/service/cloudtrail/generate.go index 1a855a86b3c..c9198421ecd 100644 --- a/internal/service/cloudtrail/generate.go +++ b/internal/service/cloudtrail/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ListTagsOp=ListTags -ListTagsInIDElem=ResourceIdList --ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=ResourceTagList[0].TagsList -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceId -TagInTagsElem=TagsList -UntagOp=RemoveTags -UntagInNeedTagType -UntagInTagsElem=TagsList -UpdateTags +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ListTagsInIDElem=ResourceIdList --ListTagsInIDNeedValueSlice=yes -ListTagsOutTagsElem=ResourceTagList[0].TagsList -ServiceTagsSlice -TagOp=AddTags -TagInIDElem=ResourceId -TagInTagsElem=TagsList -UntagOp=RemoveTags -UntagInNeedTagType -UntagInTagsElem=TagsList -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/cloudtrail/tags_gen.go b/internal/service/cloudtrail/tags_gen.go index d42318a3416..07afc92ddbb 100644 --- a/internal/service/cloudtrail/tags_gen.go +++ b/internal/service/cloudtrail/tags_gen.go @@ -24,14 +24,22 @@ func listTags(ctx context.Context, conn *cloudtrail.Client, identifier string, o input := &cloudtrail.ListTagsInput{ ResourceIdList: tfslices.Of(identifier), } + var output []awstypes.Tag - output, err := conn.ListTags(ctx, input, optFns...) + pages := cloudtrail.NewListTagsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) - if err != nil { - return tftags.New(ctx, nil), err + if err != nil { + return tftags.New(ctx, nil), err + } + + for _, v := range page.ResourceTagList[0].TagsList { + output = append(output, v) + } } - return KeyValueTags(ctx, output.ResourceTagList[0].TagsList), nil + return KeyValueTags(ctx, output), nil } // ListTags lists cloudtrail service tags and set them in Context. diff --git a/internal/service/ec2/generate.go b/internal/service/ec2/generate.go index e57b973bae8..8cafca14ba1 100644 --- a/internal/service/ec2/generate.go +++ b/internal/service/ec2/generate.go @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/tagresource/main.go -IDAttribName=resource_id -UpdateTagsFunc=updateTagsV2 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInFiltIDName=resource-id -ListTagsInIDElem=Resources -ServiceTagsSlice -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags -//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -GetTag -ListTagsOp=DescribeTags -ListTagsInFiltIDName=resource-id -ServiceTagsSlice -TagsFunc=TagsV2 -KeyValueTagsFunc=keyValueTagsV2 -GetTagsInFunc=getTagsInV2 -SetTagsOutFunc=setTagsOutV2 -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedValueSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UpdateTagsFunc=updateTagsV2 -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags -- tagsv2_gen.go +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInFiltIDName=resource-id -ListTagsInIDElem=Resources -ServiceTagsSlice -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -GetTag -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInFiltIDName=resource-id -ServiceTagsSlice -TagsFunc=TagsV2 -KeyValueTagsFunc=keyValueTagsV2 -GetTagsInFunc=getTagsInV2 -SetTagsOutFunc=setTagsOutV2 -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedValueSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UpdateTagsFunc=updateTagsV2 -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags -- tagsv2_gen.go //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeSpotFleetInstances,DescribeSpotFleetRequestHistory,DescribeVpcEndpointServices //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/ec2/tags_gen.go b/internal/service/ec2/tags_gen.go index 6de6af4fb4c..ed9dadef841 100644 --- a/internal/service/ec2/tags_gen.go +++ b/internal/service/ec2/tags_gen.go @@ -28,14 +28,27 @@ func listTags(ctx context.Context, conn ec2iface.EC2API, identifier string) (tft }, }, } + var output []*ec2.TagDescription - output, err := conn.DescribeTagsWithContext(ctx, input) + err := conn.DescribeTagsPagesWithContext(ctx, input, func(page *ec2.DescribeTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Tags { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags), nil + return KeyValueTags(ctx, output), nil } // ListTags lists ec2 service tags and set them in Context. diff --git a/internal/service/efs/generate.go b/internal/service/efs/generate.go index 87e0cb30452..d9782cec2ac 100644 --- a/internal/service/efs/generate.go +++ b/internal/service/efs/generate.go @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //go:generate go run ../../generate/listpages/main.go -ListOps=DescribeMountTargets -InputPaginator=Marker -OutputPaginator=NextMarker -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsInIDElem=FileSystemId -ServiceTagsSlice -TagInIDElem=ResourceId -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=DescribeTags -ListTagsOpPaginated -ListTagsInIDElem=FileSystemId -ServiceTagsSlice -TagInIDElem=ResourceId -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/efs/tags_gen.go b/internal/service/efs/tags_gen.go index e17108f0cbf..0d772a011ef 100644 --- a/internal/service/efs/tags_gen.go +++ b/internal/service/efs/tags_gen.go @@ -23,14 +23,27 @@ func listTags(ctx context.Context, conn efsiface.EFSAPI, identifier string) (tft input := &efs.DescribeTagsInput{ FileSystemId: aws.String(identifier), } + var output []*efs.Tag - output, err := conn.DescribeTagsWithContext(ctx, input) + err := conn.DescribeTagsPagesWithContext(ctx, input, func(page *efs.DescribeTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Tags { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags), nil + return KeyValueTags(ctx, output), nil } // ListTags lists efs service tags and set them in Context. diff --git a/internal/service/sagemaker/generate.go b/internal/service/sagemaker/generate.go index 8d0db66e7bd..905835d9de6 100644 --- a/internal/service/sagemaker/generate.go +++ b/internal/service/sagemaker/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ServiceTagsSlice -TagOp=AddTags -UntagOp=DeleteTags -UpdateTags +//go:generate go run ../../generate/tags/main.go -ListTags -ListTagsOp=ListTags -ListTagsOpPaginated -ServiceTagsSlice -TagOp=AddTags -UntagOp=DeleteTags -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/sagemaker/tags_gen.go b/internal/service/sagemaker/tags_gen.go index fe4c6376f45..6fe4d6b0c9d 100644 --- a/internal/service/sagemaker/tags_gen.go +++ b/internal/service/sagemaker/tags_gen.go @@ -23,14 +23,27 @@ func listTags(ctx context.Context, conn sagemakeriface.SageMakerAPI, identifier input := &sagemaker.ListTagsInput{ ResourceArn: aws.String(identifier), } + var output []*sagemaker.Tag - output, err := conn.ListTagsWithContext(ctx, input) + err := conn.ListTagsPagesWithContext(ctx, input, func(page *sagemaker.ListTagsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Tags { + if v != nil { + output = append(output, v) + } + } + + return !lastPage + }) if err != nil { return tftags.New(ctx, nil), err } - return KeyValueTags(ctx, output.Tags), nil + return KeyValueTags(ctx, output), nil } // ListTags lists sagemaker service tags and set them in Context.