Buy the Metrocard when you get to Jamaica Station
I would recommend buying the Metrocard when you get to Jamaica Station. There is a limited variety of Metrocard denominations available when you buy at the newstands at JFK. When you purchase a Metrocard from the vending machines at Jamaica Station, you can buy exactly the amount that you need, whether it's just $5.00 to pass through the AirTrain fare gate, or more, to use on NYC subways and busses. And remember: if you spend $10 or more on a single Metrocard (either at the JFK newstands or at a Metrocard vending machine) you will receive a 20% fare "bonus": so paying $10 will get you a $12 Metrocard; paying $12.50 will get you a $15 Metrocard, etc.
As previously noted, there are lots of Metrocard vending machines available at the Jamaica AirTrain terminal. It is inconceivable to me that they would all be out of service at the same time, and if they were, I expect that the attendants would have to open the fare gates to let arriving passengers through for free, rather than hold them hostage until the machines were fixed.