You can first compute the average PD - few choices would be:
Simple average of the individual PDs
Exposure weighted average of the PDs
If the PDs range is too large, then you might want to bucket them and apply the Vasicek formula to each bucket - this is how Basel approaches it.
Once you have the PD and LGD, then you can solve for the correlation. This is ...
It may help to consider the more familiar analogies with someone who is long a risky bond (or, in contrast, is short a risky bond, which can also be done as an alternative to buying CDS protection).
Someone who is long a risky bond loses money if the bond defaults; and also loses money (unrealized loss) if the bond's credit spread widens. They make money (...