Skip to content

Commit

Permalink
Update the list function to make the Get Cluster API call
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI committed Feb 19, 2025
1 parent 9fedb7b commit 3d0278a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion aws/table_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,20 @@ func listEcsServices(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrate
return nil, err
}

// Get cluster details
cluster := h.Item.(types.Cluster)

// The List Clusters API does not return the cluster name. Therefore, for clusters using the older ARN format, we make a Get API call to retrieve the cluster name.
// We need the cluster name to make the List tag API call for service.
if len(strings.Split(*cluster.ClusterArn, "/")) < 3 {
res, err := getEcsCluster(ctx, d, h)
if err != nil {
plugin.Logger(ctx).Error("aws_ecs_service.listEcsServices.getEcsCluster", "api_error", err)
return nil, err
}

cluster = res.(types.Cluster)
}

// Limiting the results
maxLimit := int32(10)
if d.QueryContext.Limit != nil {
Expand Down

0 comments on commit 3d0278a

Please sign in to comment.