Currently (November 2018), there is no easy way to list all IPs in-use (or reserved but not in-use) in a particular subnet in a shared VPC. IP addresses are attached to resources (e.g. an instance or a forwarding rule) which are listed in service projects. This means that one has to scan through all service projects exhaustively, collect all IPs in-use or reserved, and then organize them by subnets
Follow the recommended authentication method described here
Basically:
export GOOGLE_APPLICATION_CREDENTIALS=<path to service account key>
go run main.go <host-project>
- command line arguments
- options for console output and/or markdown files
- calculate statistics (number of available and used IPs)
- better feedback for permission issues accessing projects