Skip to content

Commit

Permalink
Update the Get Cluster API call to be happen under the getEcsServiceTags
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI committed Feb 19, 2025
1 parent 3d0278a commit ef53852
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions aws/table_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,6 @@ func listEcsServices(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrate

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 Expand Up @@ -367,6 +355,18 @@ func getEcsServiceTags(ctx context.Context, d *plugin.QueryData, h *plugin.Hydra
// RequestID: 076ed52f-8f0e-43b9-af89-3728995bb52b, InvalidParameterException: Long arn format must be used for tagging operations.
resourceArnSplitPart := strings.Split(resourceArn, "/")
if len(resourceArnSplitPart) < 3 {
// 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.
h.Item = types.Cluster{ClusterArn: data.ClusterArn}
res, err := getEcsCluster(ctx, d, h)
if err != nil {
plugin.Logger(ctx).Error("aws_ecs_service.getEcsServiceTags.getEcsCluster", "api_error", err)
return nil, err
}

cluster := res.(types.Cluster)
data.ClusterName = cluster.ClusterName

resourceArn = resourceArnSplitPart[0] + "/" + *data.ClusterName + "/" + *data.ServiceName
}

Expand Down

0 comments on commit ef53852

Please sign in to comment.