[英]Python and boto with autoscaling — How to connect to a region
如何將連接對象連接到區域? 我可以創建一個連接。 我可以連接到一個區域。 如何將連接對象鏈接到區域
region = 'ap-southeast-2'
conn = AutoScaleConnection(aws_access_key_id, aws_secret_access_key)
autoscale = boto.ec2.autoscale.connect_to_region(region)
方法connect_to_region
出現在每個boto模塊中,是創建與服務的連接的最佳方法。 在這種情況下,該方法返回一個AutoScaleConnection對象,因此無需嘗試直接創建連接對象。 因此,類似這樣的方法將起作用:
import boto.ec2.autoscale
region = 'ap-southeast-2'
conn = boto.ec2.autoscale.connect_to_region(region, aws_access_key_id="<access_key", aws_secret_access_key="<secret_key>")
mygroups = conn.get_all_groups()
...
我無法獲得garnaat的解決方案來為我工作,但這可行:
regionObj = [region for region in boto.ec2.autoscale.regions() if region.name == 'ap-southeast-2'][0]
as_conn = AutoScaleConnection(api_key, api_secret_key, region=regionObj)
mygroups = as_conn.get_all_groups()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.