Since the deployment id (or run id) is passed into every virtual machine through the contextualisation file, you can retrieve the id by running:

grep DIID /var/lib/cloud/instance/user-data.txt


and you'll find the run ID.