$\newcommand{\var}{\operatorname{var}} \newcommand{\E}{\mathbb{E}}$ jbowman has already mentioned the law of total variance, but I think the matter can be stated more simply than in that answer.
$$ \var(S) = \var(\E(S\mid D)) + \E(\var(S\mid D)). $$ I.e. the total variance of $S$ is the variance of the conditional expected value plus the expected value of the conditional variance. Below I'll say something about what that means.
You throw two 6-sided dice and get a number $D$ in the set $\{2,3,4,\ldots,12\}$, with respective probabilities $1/36, 2/36, 3/36, 4/36, 5/36, 6/36, 7/36, 6/36, 5/36,4/36,3/36,2/36,1/36$. We have $\E(D)=7$ and $\var(D)=35/6$.
Now suppose you throw a 15-sided die. You get a mean of $8$ and a variance of $56/3$ (if my hasty arithmetic is right).
If you throw $d$ 15-sided dice and sum the outcomes, you have a mean of $8d$ and a variance of $56d/3$.
So the conditional expected value of the sum $S$ given the event that $D=d$ is $8d$ and the conditional variance of the sum $S$ given the event that $D=d$ is $56d/3$. I.e. $$ \E(S\mid D=d) = 8d,\qquad \var(S\mid D=d)=\frac{56d}{3}. $$
Next we have $\E(S\mid D)$ and $\var(S\mid D)$ as random variables in their own right, since they depend on the random variable $D$, and we get: $$ \E(S\mid D) = 8D, \qquad \var(S\mid D)= \frac{56D}{3}. $$
So $$ \E(\var(S\mid D)) = \E\left(\frac{56D}{3}\right) = \frac{56}{3} \E(D) = \frac{56}{3}\cdot 7 = \frac{392}{3}, $$ and $$ \var(E(S\mid D)) = \var(8D) = 8^2\var(D) = 64\cdot \frac{35}{6} = \frac{1120}{3}. $$
Now add: $$ \frac{392}{3} + \frac{1120}{3} = \frac{1512}{3} = 504. $$
Later note: $\var(\E(S\mid D))$ is the part of the variance of $S$ that is "explained" by the variability of $D$. The other term, $\E(\var(S\mid D))$ is the part of the variance of $S$ that comes from the randomness that remains in $S$ after $D$ is determined, so it's the "unexplained" component of the variance of $S$.