简体   繁体   English

如何连接到 boto3 中的区域

[英]how to connect to region in boto3

How can one achieve the command:如何实现命令:

boto.ec2.connect_to_region()

using the boto3 suite?使用 boto3 套件? It seems not to be at a glance in the docs 文档中似乎没有一目了然

I guess it's a simpler and more precise question than the extense answer you can find in the following post .我想这是一个比您可以在以下帖子中找到的扩展答案更简单和更精确的问题。

Thanks for any help谢谢你的帮助

boto3 wants you to specify the region by default. boto3 希望您默认指定区域。 So, the solutions for you in Python is:因此,在 Python 中为您提供的解决方案是:

>>> import boto3
>>> boto_client = boto3.client('ec2', region_name='us-west-2')

You can also set up a default region.您还可以设置默认区域。 In order to do so:为此:

>>> import boto3
>>> boto_client = boto3.setup_default_session(region_name='us-west-2')
>>> boto_client = boto3.client('ec2')

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

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