Coming to power during the height of the Cold War in 1960, no one was more cognizant of the importance of anti-communist rhetoric as part of one's public posture than JFK. However, it has become clearer with the passage of time that Kennedy's true convictions were partly hidden for this reason.
But they were also partly in evidence, especially during the failed Bay of Pigs operation in April of 1961 when he remained adamant in his refusal to provide air support for the Cuban 2506 Brigade, since he believed that in doing so, he would drag the United States into a full-scale war with Cuba. More than a year later, he would again refuse to invade during the Cuban Missile Crisis after the Soviet Union had installed nuclear warheads on the island, and the fate of the world hung in the balance.
Kennedy's decision not to invade or take aggressive action on both occasions were strongly opposed by the Joint Chiefs of Staff, putting the president at odds with the Pentagon for the remaining year of his life.
The situation in Vietnam, while less dramatic, was more complex. JFK had long been sympathetic to the desire of the Vietnamese people to throw off the yoke of colonialism but inherited a questionable incursion from the Eisenhower administration to prevent the advance of Communism under the influence of the canard-like "domino theory."
From the beginning of his tenure in the White House, Kennedy had resisted the exhortations of his more hawkish advisers and the Joint Chiefs to augment the cadre of 16,000 "special advisors," already in country, with ground troops.
As Kennedy's Secretary of State, Robert McNamara revealed only in 1995 during meetings of the National Security Council in the early days of October 1963, the president expressed his intention to withdraw from Vietnam, saying, "We need to get out of Vietnam, and this is a way of doing it," and signing NSAM 263, which called for the withdrawal of 1,000 of the advisors from Vietnam as an initial gesture.
Then, on November 1, the president of South Vietnam, Ngo Dinh Diem, was deposed and murdered in a coup. The seeds of the coup had been planted in late August, when JFK and McNamara were on vacation by the anti-Diem faction among Kennedy's advisors, including Averill Harriman and Henry C. Lodge, through a cable impossible for the president to reverse. Three weeks later the president himself was assassinated. Not long thereafter, NSAM 263 was rescinded and the escalation of the war began. What would have happened in Vietnam if JFK had lived will never be known.