A colostomy is a surgical procedure performed to attach the end of the large intestine to the abdominal wall to compensate for the loss of the colon, anus and/or rectum. This allows the stool to still leave the body in an orderly fashion, as it is collected in the bag attached to the abdomen.
This surgery is generally performed on colorectal cancer patients whose life is at stake if their colon is not removed. Temporary colostomies are performed after corrective/repair surgery is performed on the colon or rectum that requires a certain period of "rest". In these cases, the colostomy is reversed once these structures are healed and fully capable of passing feces as normal.
Colostomies are performed through open surgery, which requires general anesthesia and thus poses certain risks to the patient undergoing the procedure.