Yes the resistor is to limit current through the LED.
The resistance value can be calculated using the equation
R = (Vs - Vf)/If
Where
Vs = AC RMS Supply Voltage Or DC Supply Voltage
Vf = Forward Cut-In Voltage of LED (Generally >= 1.5V)
If = Forward Current of LED (depends on LED type & intensity >= 1mA)