【发布时间】:2018-05-26 03:50:40
【问题描述】:
我在我的代码中打印出 AWS_REGION 的 env 变量值,以便我可以确认该变量确实存在,但我仍然从 Boto3 对象实例方法获得 NoRegionError()。我如何确认 Boto3 方法期望什么,以便我更正此错误?另外,“客户端”对象不使用 AWS_REGION 环境变量吗?
if choice == 'a'
st_id = "xxxdhfda-sfffg"
print("st id is:")
print(st_id)
print("region is:")
print(os.environ['AWS_REGION'])
#sfleet.cancel_sfleet_request(sfleet)
# low level ec2 client
client = boto3.client('ec2')
client.cancel_spot_fleet_requests(
SpotFleetRequestIds = [ st_id ],
TerminateInstances=True
)
else:
return False
输出:
region is:
us-east-1
:
:
:
File "/usr/lib/python2.7/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition
raise NoRegionError()
NoRegionError: You must specify a region.
【问题讨论】:
标签: python amazon-web-services amazon-ec2 boto3