@@ -70,7 +70,11 @@ func (a *mqlAwsEks) getClusters(conn *connection.AwsConnection) []*jobpool.Job {
7070 }
7171
7272 for _ , clusterName := range page .Clusters {
73- // If tag filters are active, we need to describe the cluster to check tags
73+ clusterArn := fmt .Sprintf ("arn:aws:eks:%s:%s:cluster/%s" , region , conn .AccountId (), clusterName )
74+
75+ // If tag filters are active, we need to describe the cluster to check tags.
76+ // Cache the response to avoid a redundant call in fetchDetail().
77+ var cachedDescribe * ekstypes.Cluster
7478 if conn .Filters .General .HasTags () {
7579 descResp , err := svc .DescribeCluster (ctx , & eks.DescribeClusterInput {Name : aws .String (clusterName )})
7680 if err != nil {
@@ -83,9 +87,13 @@ func (a *mqlAwsEks) getClusters(conn *connection.AwsConnection) []*jobpool.Job {
8387 log .Debug ().Str ("cluster" , clusterName ).Msg ("skipping eks cluster due to filters" )
8488 continue
8589 }
90+ cachedDescribe = descResp .Cluster
91+ // Use the real ARN from the API (handles partitions correctly)
92+ if descResp .Cluster .Arn != nil {
93+ clusterArn = * descResp .Cluster .Arn
94+ }
8695 }
8796
88- clusterArn := fmt .Sprintf ("arn:aws:eks:%s:%s:cluster/%s" , region , conn .AccountId (), clusterName )
8997 args := map [string ]* llx.RawData {
9098 "name" : llx .StringData (clusterName ),
9199 "arn" : llx .StringData (clusterArn ),
@@ -96,6 +104,14 @@ func (a *mqlAwsEks) getClusters(conn *connection.AwsConnection) []*jobpool.Job {
96104 if err != nil {
97105 return nil , err
98106 }
107+ // If we already described the cluster for tag filtering, cache it
108+ // to avoid a redundant DescribeCluster call in fetchDetail()
109+ if cachedDescribe != nil {
110+ cast := mqlCluster .(* mqlAwsEksCluster )
111+ if err := cast .populateFromDescribe (cachedDescribe ); err != nil {
112+ return nil , err
113+ }
114+ }
99115 res = append (res , mqlCluster )
100116 }
101117 }
@@ -135,8 +151,18 @@ func (a *mqlAwsEksCluster) fetchDetail() error {
135151 a .fetchErr = err
136152 return err
137153 }
138- cluster := descResp .Cluster
154+ if err := a .populateFromDescribe (descResp .Cluster ); err != nil {
155+ a .fetched = true
156+ a .fetchErr = err
157+ return err
158+ }
159+ return nil
160+ }
139161
162+ // populateFromDescribe sets all computed fields from a DescribeCluster response.
163+ // Called from fetchDetail() and also from getClusters() when tag filtering is active
164+ // (to avoid a redundant DescribeCluster call).
165+ func (a * mqlAwsEksCluster ) populateFromDescribe (cluster * ekstypes.Cluster ) error {
140166 a .Tags = plugin.TValue [map [string ]any ]{Data : toInterfaceMap (cluster .Tags ), State : plugin .StateIsSet }
141167 a .Endpoint = plugin.TValue [string ]{Data : convert .ToValue (cluster .Endpoint ), State : plugin .StateIsSet }
142168 a .Version = plugin.TValue [string ]{Data : convert .ToValue (cluster .Version ), State : plugin .StateIsSet }
@@ -193,8 +219,6 @@ func (a *mqlAwsEksCluster) fetchDetail() error {
193219 map [string ]* llx.RawData {"arn" : llx .StringDataPtr (cluster .RoleArn )},
194220 )
195221 if err != nil {
196- a .fetched = true
197- a .fetchErr = err
198222 return err
199223 }
200224 a .IamRole = plugin.TValue [* mqlAwsIamRole ]{Data : mqlIam .(* mqlAwsIamRole ), State : plugin .StateIsSet }
@@ -247,7 +271,10 @@ func (a *mqlAwsEksCluster) createdAt() (*time.Time, error) {
247271}
248272
249273func (a * mqlAwsEksCluster ) iamRole () (* mqlAwsIamRole , error ) {
250- return nil , a .fetchDetail ()
274+ if err := a .fetchDetail (); err != nil {
275+ return nil , err
276+ }
277+ return a .IamRole .Data , nil
251278}
252279
253280func (a * mqlAwsEksCluster ) supportType () (string , error ) {
0 commit comments