본문 바로가기
AWS

[Python] 미사용 Elastic IP 확인 및 릴리즈

by freesunny 2019. 7. 15.

미사용 Elastic IP 확인 및 릴리즈를 하는 방법

import boto3

client = boto3.client('ec2', region_name='ap-southeast-1')

addresses_dict = client.describe_addresses()
for eip_dict in addresses_dict['Addresses']:
    if "NetworkInterfaceId" not in eip_dict:
        print(eip_dict['PublicIp'])
        client.release_address(AllocationId=eip_dict['AllocationId'])