List and delete unused target pool in google cloud
Feb 12, 2021
Target pool is defined as a group of instance in google cloud which integrate with a forwarding rule that handles TCP and UDP traffic.
Below is the script to list all unused target group and store in a file, and delete it.
Some variables defined in the script:
FILENAME: To store unused target pools list.
REGION: GCP Region
PROJECT: GCP Project
Functions defined in the script:
get_unused_target_pool: Get unused target pool and store the info in a file.
delete_unused_target_pool: Read values from the file and delete the file