gpt4 book ai didi

python - 在 AWS rds 中很难找到区域名称

转载 作者:行者123 更新时间:2023-11-30 23:15:47 25 4
gpt4 key购买 nike

如何使用 boto 脚本获取 AWS 中所有 rds 实例的名称。我想编写一个 python 脚本来获取所有区域,然后显示它们的数据库实例。

最佳答案

以下内容应为您提供 RDS 的所有可用区域。

import boto.rds
regions = boto.rds.regions()

这将返回像这样的 RegionInfo 对象列表。

[RegionInfo:us-east-1,
RegionInfo:cn-north-1,
RegionInfo:ap-northeast-1,
RegionInfo:eu-west-1,
RegionInfo:ap-southeast-1,
RegionInfo:ap-southeast-2,
RegionInfo:us-west-2,
RegionInfo:us-gov-west-1,
RegionInfo:us-west-1,
RegionInfo:eu-central-1,
RegionInfo:sa-east-1]

如果您想连接到某个特定区域,例如 eu-west-1,您可以执行以下操作:

region = regions[6]
conn = region.connect()

甚至:

conn = boto.rds.connect_to_region(region.name)

关于python - 在 AWS rds 中很难找到区域名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28089057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com