@@ -35,24 +35,18 @@ def _terraform_rollback(plan: DeployPlan) -> list[str]:
3535
3636 # For each create, we need to destroy it
3737 for change in plan .creates :
38- commands .append (
39- f"terraform destroy -target={ change .address } -auto-approve"
40- )
38+ commands .append (f"terraform destroy -target={ change .address } -auto-approve" )
4139
4240 # For each destructive change (delete/replace), we need to re-apply it
4341 for change in plan .destructive_changes :
44- commands .append (
45- f"terraform apply -target={ change .address } -auto-approve"
46- )
42+ commands .append (f"terraform apply -target={ change .address } -auto-approve" )
4743
4844 # For updates, we can try to revert with the previous state
4945 for change in plan .updates :
5046 commands .append (
5147 f"# To revert { change .address } , restore previous config and run:"
5248 )
53- commands .append (
54- f"terraform apply -target={ change .address } -auto-approve"
55- )
49+ commands .append (f"terraform apply -target={ change .address } -auto-approve" )
5650
5751 if not plan .changes :
5852 commands .append ("# No changes to roll back" )
@@ -75,30 +69,34 @@ def _cloudformation_rollback(plan: DeployPlan) -> list[str]:
7569
7670 stack_name = ""
7771 if plan .raw_data :
78- stack_name = plan .raw_data .get ("StackName" , plan .raw_data .get ("StackId" , "STACK_NAME" ))
72+ stack_name = plan .raw_data .get (
73+ "StackName" , plan .raw_data .get ("StackId" , "STACK_NAME" )
74+ )
7975
8076 if not stack_name :
8177 stack_name = "STACK_NAME"
8278
8379 for change in plan .creates :
84- commands .append (
85- f"# Rollback create: remove { change .address } "
86- )
80+ commands .append (f"# Rollback create: remove { change .address } " )
8781
8882 for change in plan .destructive_changes :
89- commands .append (
90- f"# Rollback delete/replace: re-create { change .address } "
91- )
83+ commands .append (f"# Rollback delete/replace: re-create { change .address } " )
9284
9385 commands .append ("" )
9486 commands .append ("# Full stack rollback options:" )
95- commands .append ("# Option 1: Roll back the stack update (if update-rollback triggered)" )
87+ commands .append (
88+ "# Option 1: Roll back the stack update (if update-rollback triggered)"
89+ )
9690 commands .append (f"aws cloudformation rollback-stack --stack-name { stack_name } " )
9791 commands .append ("" )
9892 commands .append ("# Option 2: Delete the stack and recreate from previous template" )
9993 commands .append (f"aws cloudformation delete-stack --stack-name { stack_name } " )
100- commands .append (f"aws cloudformation wait stack-delete-complete --stack-name { stack_name } " )
101- commands .append (f"# Then redeploy with: aws cloudformation create-stack --stack-name { stack_name } ..." )
94+ commands .append (
95+ f"aws cloudformation wait stack-delete-complete --stack-name { stack_name } "
96+ )
97+ commands .append (
98+ f"# Then redeploy with: aws cloudformation create-stack --stack-name { stack_name } ..."
99+ )
102100
103101 return commands
104102
0 commit comments