In the United States, we specifically block appointment of officials to civilian office that have recently left military service with the National Security Act of 1947 [0]. A waiver from Congress is required to grant exception to this rule, and the first time that waiver was ever sought and granted was just a few years ago in 2017 for General James Mattis to serve as Secretary of Defense only a few years after retirement from the Marines.
[0] https://en.m.wikipedia.org/wiki/National_Security_Act_of_194...