This repository was archived by the owner on Oct 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
roles/aws/aws_admin_tools/templates Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments