Estonia was invaded and occupied by the USSR on June 17, 1940. Then it was conquered by the Germans before being re-annexed by the soviets in 1944.
Estonian SSR became the republic of Estonia in 1990 and was no longer a soviet republic in 1991. On August 20 of that year, it declared its independence.