参数验证失败:\ n输入中的未知参数:\“ include \”,必须是以下项之一:群集,服务

时间:2019-09-23 08:57:48

标签: aws-lambda boto3 amazon-ecs

我正在编写一个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

1 个答案:

答案 0 :(得分:0)

您遇到此错误的原因是,默认情况下,AWS lambda与旧版本的boto3一起运行。

当前AWS lamda具有以下版本:

python3.7

  • boto3-1.9.42
  • botocore-1.12.42

python3.6

  • boto3-1.7.74
  • botocore-1.10.74

python2.7

  • 不适用

参考:Lambda Runtimes

要升级boto3版本,您可以参考以下文章:

AWS Lambda Console - Upgrade boto3 version

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