Skip to content

Commit

Permalink
recreate instead of erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsiaw committed Aug 31, 2023
1 parent 36fa4e3 commit 148d1b8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/cloud_formation/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,26 @@ def create_or_update
when "CREATE_COMPLETE", "UPDATE_COMPLETE", "UPDATE_ROLLBACK_COMPLETE"
update
when "ROLLBACK_COMPLETE"
# ROLLBACK_COMPLETE only happens when creating stack failed
# The only way to solve is to delete and re-create the stack
raise CannotUpdateRolledbackStackException
try_recreate
else
raise UpdateInProgressException
end
end

def try_recreate
puts 'Attempting to re-create stack from ROLLBACK_COMPLETE'
delete

loop do
break if stack_status.nil? || stack_status == 'DELETE_COMPLETE'
puts "Waiting for stack '#{stack.name}' to delete..."
sleep 10
end

puts 'Stack deleted. Re-creating'
create
end

def in_progress?
status = stack_status
return false if status.nil?
Expand Down

0 comments on commit 148d1b8

Please sign in to comment.