Principle of double effect
The principle of double effect is not the same as "the ends justify the means." In the principle of double effect, the goal is to make something good happen, and something bad happens too.  The good and bad thing both come from the same action.  In the ends justify the means, the person does something bad to make a good thing happen.  The good thing comes from the bad action.