Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit dddefd8

Browse files
author
Matej Stajduhar
committed
Merge branch 'Updating-list-of-EC2-with-all-associated-EIPs' into Updating-list-of-EC2-with-all-associated-EIPs-PR-devel-2.x
2 parents a4837d3 + 7b94fee commit dddefd8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

roles/aws/aws_admin_tools/templates/API_GetListOfEC2.py.j2

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def lambda_handler(event, context):
1717
pub_ip = ""
1818
priv_ip = ""
1919
inst_name = ""
20+
eip_list=[]
21+
priv_eip=[]
22+
pub_eip=[]
2023

2124
if "PublicIpAddress" in instance:
2225
pub_ip = instance['PublicIpAddress']
@@ -31,6 +34,20 @@ def lambda_handler(event, context):
3134
for name in instance['Tags']:
3235
if name['Key'] == 'Name':
3336
inst_name = name['Value']
37+
38+
eip_list = ec2_cli.describe_addresses(
39+
Filters=[
40+
{
41+
'Name': 'tag:Name',
42+
'Values': [inst_name]
43+
}
44+
]
45+
)
46+
for eip in eip_list['Addresses']:
47+
if "PublicIp" in eip:
48+
pub_eip.append(eip['PublicIp'])
49+
if "PrivateIpAddress" in eip:
50+
priv_eip.append(eip['PrivateIpAddress'])
3451
else:
3552
inst_name = "-"
3653

@@ -39,7 +56,11 @@ def lambda_handler(event, context):
3956
'State': instance['State'],
4057
'Public IP': pub_ip,
4158
'Private IP': priv_ip,
42-
'Instance type': instance['InstanceType']
59+
'Instance type': instance['InstanceType'],
60+
'EIP': {
61+
'public': pub_eip,
62+
'private': priv_eip
63+
}
4364
}
4465
Ec2_info_list.append(new_dict)
4566

0 commit comments

Comments
 (0)