This paper studies the optimal tuning of the regularization parameter in LASSO or the threshold parameters in approximate message passing (AMP). Considering a model in which the design matrix and noise are zero-mean i.i.d. Gaussian, we propose a data-driven approach for estimating the regularization parameter of LASSO and the threshold parameters in AMP. Our estimates are consistent, that is, they converge to their asymptotically optimal values in probability as n, the number of observations, and p, the ambient dimension of the sparse vector, grow to infinity, while n/p converges to a fixed number .. As a byproduct of our analysis, we will shed light on the asymptotic properties of the solution paths of LASSO and AMP.