0

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
Nadeem Patel
  • 1
  • 1
  • 1
  • As the answer describes, boto3 1.9.42 didn't have the `include` option, see [documentation](https://boto3.amazonaws.com/v1/documentation/api/1.9.42/reference/services/ecs.html#ECS.Client.describe_services). – Lamanus Sep 23 '19 at 11:58

1 Answers1

0

You are encountering this error because AWS lambda by-default runs with older version of boto3.

Currently AWS lamda has following versions :

python3.7

  • boto3-1.9.42
  • botocore-1.12.42

python3.6

  • boto3-1.7.74
  • botocore-1.10.74

python2.7

  • N/A

Reference : Lambda Runtimes

To upgrade the boto3 version you can refer to following articles :

AWS Lambda Console - Upgrade boto3 version

https://www.mandsconsulting.com/lambda-functions-with-newer-version-of-boto3-than-available-by-default/

Harsh Bafna
  • 2,094
  • 1
  • 11
  • 21