python-boto3中的成本浏览器'未知服务'ce'

问题描述 投票:2回答:3

美好的一天,最新的AWS发布API,用于了解结算信息。

它在所有aws SDK(c#,python,php)中都可用。我刚尝试了一个lambda函数来更新我的数据库表,其中包含我所有链接帐户的当前成本。但是mt lambda函数不起作用。它显示以下错误

“未知服务:'ce'。有效的服务名称是:acm,apigateway,application-autoscaling,appstream,athena,autoscaling等”

我的lambda代码是:

import boto3
from datetime import datetime, timedelta
def lambda_handler(event, context):
client1 = boto3.client(
'ce',
aws_access_key_id=accesskey,
aws_secret_access_key=secretkey)
[referral link for client creation][1]
response = client1.get_cost_and_usage(
TimePeriod={
    'Start': startdate,
    'End': enddate
},
Granularity='MONTHLY',
Metrics=[
    'BlendedCost',
],
GroupBy=[
    {
        'Type': 'DIMENSION',
        'Key': 'LINKED_ACCOUNT'
    },
],
)

print response
python amazon-web-services aws-lambda boto3
3个回答
0
投票

作为mentioned in the Boto3 bugtracker,如果你更新了你的boto3而没有更新你的botocore,这可能会发生。

所以我建议更新botocore并重试:

pip install botocore --upgrade

或者以某种不同的方式,取决于你如何安装botocore。


0
投票

我认为简单的AWS Lambda团队尚未将botocore升级到最新版本。在写这篇文章的那一刻,docs for AWS Lambda提到1.7.37作为botocore的当前版本:

AWS SDK for Python 2.7(Boto 3)版本3-1.4.7 botocore-1.7.37

AWS SDK for Python 3.6(Boto 3)版本3-1.4.7 botocore-1.7.37

阅读the botocore changelog最年长提到ce是1.7.48:

1.7.48

[...]

api-change:ce:将ce客户端更新到最新版本

所以我的猜测是 - 一个AWS团队还没有发现AWS的其他团队已经发布的内容。

您可以联系AWS支持部门或等待几天。我猜。


0
投票

AWS现在更新了botocore(至少在eu-central-1中):

有效的服务名称是:acm,alexaforbusiness,apigateway,应用程序自动缩放,appstream,appsync,athena,autoscaling,批处理,预算,ce,cloud9,[...]

© www.soinside.com 2019 - 2024. All rights reserved.