I am writing a lambda to update all the services in all the ecs clusters based on their tags. For that I need to extract the tags from the description of the service but the corresponding function gives error.
import boto3
import botocore
client = boto3.client('ecs')
def lambda_handler(event, context):
responseToListClusters = client.list_clusters() #gets list of clusters
clusterArnsList=responseToListClusters['clusterArns'] #extracts list of clusterArns
for CLUSTER in clusterArnsList:
responseToListServices = client.list_services(cluster= CLUSTER) #gets list of services
serviceArnsList=responseToListServices['serviceArns'] #extracts list of serviceArns
for SERVICE in serviceArnsList:
responseToDescribeServices= client.describe_services(cluster=CLUSTER,services=[SERVICE,],include=['TAGS',])
print(responseToDescribeServices)
#client.update_service(cluster=CLUSTER,service=SERVICE,desiredCount=1) #updates all services