If your earned income for the year is less than the contribution limit (in 2017 and 2018, $5,500 for those under 50), you can only contribute up to your earned income. In other words, if your earned income is $3,000, you can only contribute up to $3,000.
Please feel free to post any additional details or questions in the comment section.