In Goldstein's Classical Mechanics, he suggests the use of Lagrange Multipliers to introduce certain types of non-holonomic and holonomic contraints into our action. The method he suggests is to define a modified Lagrangian $$L^{'}(\dot{q},q;t) = L(\dot{q},q;t) + \sum^{m}_{i = 1}\lambda_{i} f_{i}(\dot{q},q;t),$$ where $f_{i}(\dot{q},q;t)$ are $m$ equations of constraint, and $L$ the original Lagrangian. He then proceeds to define the action $S^{'} = \int_{t_{1}}^{t_{2}}L^{'}\,dt$ and takes the variation of $S^{'}$ to be zero, thus applying Hamilton's principle.
My confusion in this approach arises from the way in which the Lagrange Multipliers are introduced. I don't see why $\sum^{m}_{i = 1}\lambda_{i} f_{i}(\dot{q},q;t)$ should be introduced inside the integral.
In multivariable calculus, the Lagrange multiplier system stems from the idea that if we want to extremize a function subject to certain constraints, then the gradient of the function will be proportional to a linear combination of the gradient of the constraint equations. Here, the function in question is the action, not the Lagrangian. So, I feel like the resolution should be that $$\delta S + \delta \sum^{m}_{i = 1}\lambda_{i} f_{i}(\dot{q},q;t) = 0;\, S = \int_{t_{1}}^{t_{2}}L\,dt$$ and not $$\delta S^{'} = 0; \, S = \int_{t_{1}}^{t_{2}}L^{'}\,dt.$$
To me, it isn't clear if this makes sense or if the two methods are equivalent.