Is it possible to use a 2009 imac as a display for a 2017 macbook pro? Is it possible to use a 2009 imac as a display for a 2017 macbook pro? If so, what cable would I need to make this work? Ideally with a mini display port to usb-c cable it would just work but I have my doubts.
It appears you are describing the setup above. This is possible to do.
You will need a Mini DisplayPort to Mini DisplayPort cable and a Mini DisplayPort or Thunderbolt port on your MacBook Pro.
To start using your iMac as a display you need to enter Target Display Mode.

Follow these steps to start using your iMac as a display:
Make sure that your iMac is turned on,  and the other Mac is logged in
to a  macOS user account.
Connect the Mini DisplayPort or  Thunderbolt cable between the two
computers.     Press Command-F2 on the  keyboard of the iMac that you
want to  use as a display.

(Source)
To exit Target Display Mode:

To leave Target Display Mode, press Command-F2 on the iMac keyboard again. Your iMac also exits Target Display Mode if you disconnect the cable that connects the two computers, or if you shut down or sleep either computer.
If the connected Mac goes into sleep mode, the iMac screen turns off until you wake the other computer, or until you take your iMac out of Target Display Mode.

Using Apps

Any apps that are open on your iMac remain open and active while your iMac is in Target Display Mode.
For example, if you begin playing music in iTunes on your iMac and then activate Target Display Mode, iTunes doesn't pause on your iMac.
If you've set your iMac to automatically log out, apps are paused or closed when this happens but your iMac remains in Target Display Mode.

Connecting devices to your ports

A Mac that's connected to an iMac in Target Display Mode can't use the iMac computer's built-in camera, its USB, ThunderBolt, or FireWire ports, or devices connected to those ports. To use external devices with your Mac, connect these devices directly to the Mac that you want to use them with.