Yes, but it also is the part that the virus uses to bind to and enter a cell. It can mutate to a certain extent, but there are limitations to how much can change about it without destroying its ability to actually infect individuals.
On the other hand, there is some concern around the phenomenon known as "original antigenic sin". Its unknown if it is or will ever be an issue with Covid, but it essentially means that for some viruses (such as the flu), your immune system imprints on a virus the first time it encounters it, and more heavily relies on immunity for that particular virus than new antibodies for variants of that virus later on. This leads to the body mounting a sub-optimal defence against new strains of the virus (which is in part why we have yearly flu vaccines that don't offer amazing protection). There is some concern that there is a possibility that over time covid will continue to mutate and those whose initial infection was natural won't have as protective immunity as those who were vaccinated first, precisely because the vaccine only targets the spike protein and not the entire virus:
"Still, Hensley isn’t worried about imprinting — or at least not among people who have been vaccinated with mRNA vaccines. The very strong immune response generated by the Moderna and the Pfizer-BioNTech vaccines should override any imprinting impacts as SARS-2 mutates, he said. Hensley worries, though, that people whose immunity to the virus comes from infection, not vaccination, might have more difficulty handling variant viruses because of imprinting effects.
David Topham, an immunologist at the University of Rochester Medical Center and director of the New York Influenza Center of Excellence, also envisages that possibility.
He noted that, in the earliest stages of SARS-2 infection, the immune system mounts a response to a portion of the spike protein called S2. Later, the immune system focuses its attention on other parts of the spike, notably the part of the protein that attaches the virus to cells it invades, known as the receptor binding domain.
It’s not yet known if the early focus on S2 — which doesn’t change much from virus to virus — will blind the immune system to the changes elsewhere in the spike protein, the changes updated vaccines would be trying to teach the immune system to respond to, Topham said.
Topham doesn’t think this will be a problem in vaccinated people, because of the way the vaccines in use have been designed. The spike proteins they trigger production of appear to hide the S2 region, he said. The immune system can’t fixate on something it doesn’t see.
For people whose immunity comes from infection, Topham sees three possible scenarios. “It can be a problem, because the immune cells specific for S2 outcompete immune cells against other components of the spike protein that you really need in order to get protection. It can be inconsequential in that eventually the responses to the other parts of the protein catch up and it doesn’t matter. Or it could actually be a benefit because it gets the immune system revved up more quickly.”[0]
[0] https://www.statnews.com/2021/04/16/next-generation-covid-19...