使用 AWS System Manager 提取弹性 IP 和实例名称列表
问题描述:
在 AWS 云环境中,我必须获取具有实例名称和所有区域/可用区(如 eu-west-1、eu-west-3、ap-south-1、us-east-)的所有弹性 IP 的列表1 等.
In the AWS Cloud Environment i have to the get list of all Elastic IPs with instance name and in all region/AZs like eu-west-1 , eu-west-3, ap-south-1, us-east-1 etc..
如果可能,如何通过 AWS 系统管理器实现这一点.如果没有,那么我是否必须编写任何其他函数/代码或使用其他 AWS 功能.
How this can be achieved via AWS System manager if possible. If not, then do i have to write any other function/code or use other AWS functionality.
答
我会通过以下步骤编写程序(例如在 Python 中)来实现:
I would do it by writing a program (eg in Python) with these steps:
- 使用
describe_regions()
- 使用
describe_addresses()
- 从响应中提取
InstanceId
和PublicIp
- 调用
describe_instances()
为给定的InstanceId
获取标签列表.实例名称"存储为带有Key = 'Name'
的标签
- Loop through each (applicable) Region using
describe_regions()
- Loop through each Elastic IP address using
describe_addresses()
- Extract the
InstanceId
andPublicIp
from the response - Call
describe_instances()
for the givenInstanceId
to obtain a list of Tags. The "instance name" is stored as a Tag withKey = 'Name'
- Extract the
- Loop through each Elastic IP address using
- 从响应中提取
- 使用