2. As shown in Figure 1, in the isosceles right $\triangle ABC$, $AC = BC$. An equilateral $\triangle ABD$ is constructed with the hypotenuse $AB$ as one side, such that points $C$ and $D$ are on the same side of $AB$; then an equilateral $\triangle CDE$ is constructed with $CD$ as one side, such that points $C$ and $E$ are on opposite sides of $AB$. If $AE = 1$, then the length of $CD$ is ( ).
(A) $\sqrt{3}-1$
(B) $\sqrt{6}-2$
(C) $\frac{\sqrt{3}-1}{2}$
(D) $\frac{\sqrt{6}-\sqrt{2}}{2}$
2.D.

Since $\triangle A B C$ is an isosceles right triangle and $\triangle A B D$ is an equilateral triangle, we have $C D \perp A B$, and
$$
C D=\frac{\sqrt{3}}{2} A B-\frac{1}{2} A B=\frac{\sqrt{3}-1}{2} A B \text {. }
$$

It is easy to see that $\angle A D C=\angle A D E=30^{\circ}$, and $D E=D C$. Therefore, points $C$ and $E$ are symmetric with respect to line $A D$. Hence, $A C=A E=1$.
$$
\text { Thus, } A B=\sqrt{2} A C=\sqrt{2} \text {. }
$$

Therefore, $C D=\frac{\sqrt{3}-1}{2} \times \sqrt{2}=\frac{\sqrt{6}-\sqrt{2}}{2}$.