Translation:It took twelve months.
間 is not used for months (since the ヶ in ヶ月 already distinguishes it as a counter for a span of months, and not a single specific month)
It is required for weeks 週間
It is optional for days 日・日間 and years 年・年間 but usually not necessary. Different resources will give you different recommendations on whether or not to use it, so it may be regional differences.
It can be another resource (e.g. money), not necessarily time. 掛かる (かかる) has other meanings as well. https://jisho.org/search/%E6%8E%9B%E3%81%8B%E3%82%8B