Amazon.com Inc. shares have largely climbed on the back of two trends: strength in its cloud business and a focus on costs.