在带有b的lambda中使用get_cost_和_usage时出现错误

2024-07-04 07:25:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在使用botolambda时使用cost explorer获取前一天的成本。但我得到了错误

" "errorMessage": "An error occurred (ValidationException) when calling the GetCostAndUsage operation: " and the error type is "ClientError".

我已将区域指定为us-east-1。我的政策是

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ce:*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

我的代码在下面

^{pr2}$

Tags: thelambdaan错误errorboto成本when
1条回答
网友
1楼 · 发布于 2024-07-04 07:25:41

我认为你有两个问题:

  1. 无效的时间戳格式,这将导致如下错误:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the GetCostAndUsage operation: Start time  is invalid. Valid format is: yyyy-MM-dd.
  1. 缺少get_cost_and_usage()调用的强制Metrics关键字。在

将您的get_cost_and_usage()调用改为如下所示应该可以:

^{pr2}$

相关问题 更多 >

    热门问题