【问题标题】:Parameter validation failed:\nUnknown parameter in input: \"include\", must be one of: cluster, services参数验证失败:\n输入中的未知参数:\"include\",必须是以下之一:集群、服务
【发布时间】:2020-01-23 07:33:38
【问题描述】:

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

【问题讨论】:

  • 如答案所述,boto3 1.9.42 没有include 选项,请参阅documentation

标签: aws-lambda boto3 amazon-ecs


【解决方案1】:

您遇到此错误是因为 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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 2019-04-22
    • 2022-12-10
    • 2013-10-16
    • 2022-12-12
    • 2015-08-17
    • 1970-01-01
    相关资源
    最近更新 更多