The Complexity of Resilience Problems via Valued Constraint Satisfaction Problems