@@ -624,70 +624,53 @@ func (a *mqlAwsElasticacheUser) id() (string, error) {
624624
625625func (a * mqlAwsElasticache ) serviceUpdates () ([]any , error ) {
626626 conn := a .MqlRuntime .Connection .(* connection.AwsConnection )
627- res := []any {}
628- poolOfJobs := jobpool .CreatePool (a .getServiceUpdates (conn ), 5 )
629- poolOfJobs .Run ()
630- if poolOfJobs .HasErrors () {
631- return nil , poolOfJobs .GetErrors ()
632- }
633- for i := range poolOfJobs .Jobs {
634- if poolOfJobs .Jobs [i ].Result != nil {
635- res = append (res , poolOfJobs .Jobs [i ].Result .([]any )... )
636- }
637- }
638- return res , nil
639- }
640-
641- func (a * mqlAwsElasticache ) getServiceUpdates (conn * connection.AwsConnection ) []* jobpool.Job {
642- tasks := make ([]* jobpool.Job , 0 )
643627 regions , err := conn .Regions ()
644628 if err != nil {
645- return [] * jobpool. Job {{ Err : err }}
629+ return nil , err
646630 }
647- for _ , region := range regions {
648- f := func () (jobpool.JobResult , error ) {
649- svc := conn .Elasticache (region )
650- ctx := context .Background ()
651- res := []any {}
652- paginator := elasticache .NewDescribeServiceUpdatesPaginator (svc , & elasticache.DescribeServiceUpdatesInput {})
653- for paginator .HasMorePages () {
654- page , err := paginator .NextPage (ctx )
655- if err != nil {
656- if Is400AccessDeniedError (err ) || IsServiceNotAvailableInRegionError (err ) {
657- log .Warn ().Str ("region" , region ).Msg ("error accessing region for AWS API" )
658- return res , nil
659- }
660- return nil , err
661- }
662- for _ , su := range page .ServiceUpdates {
663- mqlSu , err := CreateResource (a .MqlRuntime , ResourceAwsElasticacheServiceUpdate ,
664- map [string ]* llx.RawData {
665- "__id" : llx .StringData (fmt .Sprintf ("elasticache/serviceupdate/%s/%s" , region , convert .ToValue (su .ServiceUpdateName ))),
666- "name" : llx .StringDataPtr (su .ServiceUpdateName ),
667- "region" : llx .StringData (region ),
668- "description" : llx .StringDataPtr (su .ServiceUpdateDescription ),
669- "engine" : llx .StringDataPtr (su .Engine ),
670- "engineVersion" : llx .StringDataPtr (su .EngineVersion ),
671- "severity" : llx .StringData (string (su .ServiceUpdateSeverity )),
672- "status" : llx .StringData (string (su .ServiceUpdateStatus )),
673- "updateType" : llx .StringData (string (su .ServiceUpdateType )),
674- "releaseDate" : llx .TimeDataPtr (su .ServiceUpdateReleaseDate ),
675- "recommendedApplyByDate" : llx .TimeDataPtr (su .ServiceUpdateRecommendedApplyByDate ),
676- "endDate" : llx .TimeDataPtr (su .ServiceUpdateEndDate ),
677- "estimatedUpdateTime" : llx .StringDataPtr (su .EstimatedUpdateTime ),
678- "autoUpdateAfterRecommendedApplyByDate" : llx .BoolDataPtr (su .AutoUpdateAfterRecommendedApplyByDate ),
679- })
680- if err != nil {
681- return nil , err
682- }
683- res = append (res , mqlSu )
684- }
631+ if len (regions ) == 0 {
632+ return nil , nil
633+ }
634+ // Service updates are global; fetch from the first available region.
635+ region := regions [0 ]
636+ svc := conn .Elasticache (region )
637+ ctx := context .Background ()
638+ res := []any {}
639+ paginator := elasticache .NewDescribeServiceUpdatesPaginator (svc , & elasticache.DescribeServiceUpdatesInput {})
640+ for paginator .HasMorePages () {
641+ page , err := paginator .NextPage (ctx )
642+ if err != nil {
643+ if Is400AccessDeniedError (err ) || IsServiceNotAvailableInRegionError (err ) {
644+ log .Warn ().Str ("region" , region ).Msg ("error accessing region for AWS API" )
645+ return res , nil
685646 }
686- return jobpool .JobResult (res ), nil
647+ return nil , err
648+ }
649+ for _ , su := range page .ServiceUpdates {
650+ mqlSu , err := CreateResource (a .MqlRuntime , ResourceAwsElasticacheServiceUpdate ,
651+ map [string ]* llx.RawData {
652+ "__id" : llx .StringData (fmt .Sprintf ("elasticache/serviceupdate/%s" , convert .ToValue (su .ServiceUpdateName ))),
653+ "name" : llx .StringDataPtr (su .ServiceUpdateName ),
654+ "region" : llx .StringData (region ),
655+ "description" : llx .StringDataPtr (su .ServiceUpdateDescription ),
656+ "engine" : llx .StringDataPtr (su .Engine ),
657+ "engineVersion" : llx .StringDataPtr (su .EngineVersion ),
658+ "severity" : llx .StringData (string (su .ServiceUpdateSeverity )),
659+ "status" : llx .StringData (string (su .ServiceUpdateStatus )),
660+ "updateType" : llx .StringData (string (su .ServiceUpdateType )),
661+ "releaseDate" : llx .TimeDataPtr (su .ServiceUpdateReleaseDate ),
662+ "recommendedApplyByDate" : llx .TimeDataPtr (su .ServiceUpdateRecommendedApplyByDate ),
663+ "endDate" : llx .TimeDataPtr (su .ServiceUpdateEndDate ),
664+ "estimatedUpdateTime" : llx .StringDataPtr (su .EstimatedUpdateTime ),
665+ "autoUpdateAfterRecommendedApplyByDate" : llx .BoolDataPtr (su .AutoUpdateAfterRecommendedApplyByDate ),
666+ })
667+ if err != nil {
668+ return nil , err
669+ }
670+ res = append (res , mqlSu )
687671 }
688- tasks = append (tasks , jobpool .NewJob (f ))
689672 }
690- return tasks
673+ return res , nil
691674}
692675
693676func (a * mqlAwsElasticacheServiceUpdate ) id () (string , error ) {
0 commit comments