繁体   English   中英

Boto3 botocore.exceptions.EndpointConnectionError

[英]Boto3 botocore.exceptions.EndpointConnectionError

我正在尝试获取某个区域中所有带有标签{'key': 'string', 'Values':['string']}资源的每日成本,为此我使用boto3 CostExplorer API。

但我收到错误botocore.exceptions.EndpointConnectionError: 无法连接到端点 URL:“ https://ce.eu-west-3.amazonaws.com/

这是我正在使用的代码

import boto3

client = boto3.client('ce')

response = client.get_cost_and_usage(
    TimePeriod={
        'Start': '2020-02-01',
        'End': '2020-03-01'
    },
    Metrics=['BlendedCost'],
    Granularity='DAILY',
    Filter={
         'Tags': {'Key': 'string', 'Values': ['string']}
     }
)

print(response)

AWS Cost Explorer 目前仅在 us-east-1 中可用。

有关当前受支持区域列表,请参阅此链接:Amazon Cost Explorer Supported Regions AWS Service Endpoints

在此处输入图片说明

解析度:

您需要在.aws/config 中相应地更改区域

或在为 AWS Cost Explorer 创建客户端时设置正确的区域,如下所示:

import boto3

ce-client = boto3.client('ce', region_name='us-east-1')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM