using bash script how do I get a list all the services in ecs for all the ecs clusters.
ecscluster=$(aws ecs list-clusters)
aws ecs list-services --cluster $ecscluster
I don't think the other answer will work as list clusters will return a json not the cluster names only, here's a slightly modified version of the same command that will work:
all_services="$(for ecscluster in $(
aws ecs list-clusters --query 'clusterArns' --output text); do aws ecs list-services --cluster $ecscluster; done)"
echo $all_services
It will return a json containing ARNs for services grouped by Cluster, and you can use something like jq to better process.
This might achieve what you needed:
all_services="$(for ecscluster in $(
aws ecs list-clusters); do aws ecs list-services --cluster $ecscluster; done)"
echo "$all_services"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.