Take a try and peek on epheph/ec2-check-reserved-instances[1], it is pretty old and looks unmaintained, but still could give some idea. [1] https://github.com/epheph/ec2-check-reserved-instances