我正在编写一个lambda以根据其标签更新所有ecs集群中的所有服务。为此,我需要从服务的描述中提取标签,但相应的功能会出错。
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
答案 0 :(得分:0)
您遇到此错误的原因是,默认情况下,AWS lambda与旧版本的boto3一起运行。
当前AWS lamda具有以下版本:
python3.7
python3.6
python2.7
要升级boto3版本,您可以参考以下文章: