The noun deterrent means something that prevents someone from doing something by making them afraid of consequences.
Synonyms are restraint, obstacle, hindrance, or discouragement.
The word origins from Latin (1829) deterrentem, present participle of deterrere meaning “to frighten from, discourage from”. It comes from de meaning “away” plus terrere meaning “frighten, fill with fear”.
The minority celebrated the deterrent effect of the new law that was passed.
This is a serious deterrent to the country.
To protect them, iron-made doors are an effective deterrent.