Skip to main content
 首页 » 编程设计

python之AWS 产品 API : what is the correct regional location and url for us west 2

2025年05月04日21lyj

我正在使用 boto3 定价客户端来获得按需定价,因为 boto3 ec2 客户端没有按需定价,而是现货定价。

这给了我错误提示 Could not connect to the endpoint URL: "https://api.pricing.us-west-2.amazonaws.com/。

下面我们西部的正确区域名称或位置值是什么 2. 我检查了这些区域,这是正确的。定价 api 不在俄勒冈地区吗?

        pricing = boto3.client('pricing', region_name='us-west-2') 
        response = pricing.get_products( 
        ServiceCode='AmazonEC2', 
        Filters=[ 
            {'Type': 'TERM_MATCH', 'Field': 'operatingSystem', 'Value': 'Linux'}, 
            {'Type':'TERM_MATCH', 'Field': 'location', 'Value': 'US West (Oregon)'} 
 
        ], 
        MaxResults=20 
    ) 
 
    for price in response['PriceList']: 
        resp = json.loads(price) 
        on_demand = resp['terms']['OnDemand'] 
        print len(on_demand) 
        print(on_demand) 

请您参考如下方法:

AWS 价目表服务 API 仅支持两个服务端点:

您需要从其中选择一个。不支持 us-west-2。