I see that André answered this while I was out putting $52$ miles on my bicycle, but let me suggest a very slightly different route to the same recurrence that occurred to me during my ride. I’ll use the same good terminology and the same definition of $a_n$, and I’ll let $c_n$ be the number of good strings of length $n$ that do not end in $1$ or $2$.
Suppose that $\sigma$ is a good string of length $n\ge 1$. No matter what the last digit of $\sigma$ is, there are at least $9$ digits that I can append to $\sigma$ to make a good string of length $n+1$, and if the last digit of $\sigma$ is not $1$ or $2$, I can append any of the $10$ digits. This accounts for all possible good strings of length $n+1$, so $a_{n+1}=9a_n+b_n$. How many of these do not end in $1$ or $2$? Precisely the ones obtained by appending one of the $8$ digits in $\{0,3,4,5,6,7,8,9\}$ to a good string of length $n$, of which there are $8a_n$. Thus, $b_{n+1}=8a_n$, so $b_n=8a_{n-1}$, and
$$a_{n+1}=9a_n+b_n=9a_n+8a_{n-1}\;.$$
Thus, we have
$$\left\{\begin{align*}
&a_0=1\\
&a_1=10\\
&a_n=9a_{n-1}+8a_{n-2}\quad\text{for}\quad n\ge 2\;.
\end{align*}\right.$$
That’s as far as you had to go, but I was curious about a closed form for $a_n$. By standard techniques one can discover that
$$a_n=\frac1{226}\left(\left(113+11\sqrt{113}\right)\left(\frac{9+\sqrt{113}}2\right)^n+\left(113-11\sqrt{113}\right)\left(\frac{9-\sqrt{113}}2\right)^n\right)\;.$$
Now $$\left|\frac{9-\sqrt{113}}2\right|<1\quad\text{and}\quad\left|\frac{113-11\sqrt{113}}{226}\right|<0.02\;,$$
and $a_n$ is always an integer, so for $n\ge 1$ $a_n$ is the integer closest to
$$\frac{113+11\sqrt{113}}{226}\left(\frac{9+\sqrt{113}}2\right)^n\;.\tag{1}$$
$(1)$ is approximately $(1.017396477611)(9.815072906367)^n$.
For $n=7$ this evaluates to approximately $8,927,809.995842$, which rounds to $8,927,810$, the correct value, so the approximation is pretty good.