Key to success
Amendment to the constitution
Secret to/of success
The first two are things done to something. The key unlocks success, the amendment changes the constitution
The secret can be thought of as either something leading you to success or as something belonging to success, a derivative of success so, for me, that allows the use of to or of
This is how it feels to me. We don't really say, key of success or amendment of the constitution.