Module: Jets::Cfn::Stack::Rollback

Includes:
AwsServices::AwsHelpers, Util::Logging
Included in:
Jets::Cfn::Stack
Defined in:
lib/jets/cfn/stack/rollback.rb

Instance Method Summary collapse

Methods included from Util::Logging

#log

Methods included from AwsServices::AwsHelpers

#find_stack

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Instance Method Details

#continue_update_rollback!Object

Super edge case: UPDATE_ROLLBACK_FAILED status The continue_update_rollback! addresses this edge case. Note: We do not provide any resources to skip. Also, tough to reproduce this edge case. Unsure how got to it.

Related: Gist with Error: gist.github.com/tongueroo/d752186375ea95ed310e6735de24a324 AWS Troubleshooting Update rollback failed: go.aws/49m3Ji3 AWS cli continue-update-rollback: go.aws/43OiLw2



15
16
17
18
19
20
21
22
# File 'lib/jets/cfn/stack/rollback.rb', line 15

def continue_update_rollback!
  return unless update_rollback_failed?

  log.info "Continuing update rollback"
  cfn.continue_update_rollback(stack_name: stack_name)
  cfn_status.wait
  cfn_status.reset
end

#delete_rollback_complete!Object

Delete existing rollback stack from previous bad bootstrap deploy



32
33
34
35
36
37
38
39
40
# File 'lib/jets/cfn/stack/rollback.rb', line 32

def delete_rollback_complete!
  return unless rollback_complete?

  log.info "Existing stack is in ROLLBACK_COMPLETE"
  log.info "Deleting stack before continuing"
  cfn.delete_stack(stack_name: stack_name)
  cfn_status.wait
  cfn_status.reset
end

#rollback_complete?Boolean

Checks for a few things before deciding to delete the parent stack

* Parent stack status status is ROLLBACK_COMPLETE
* Parent resources are in the DELETE_COMPLETE state

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jets/cfn/stack/rollback.rb', line 47

def rollback_complete?
  stack = find_stack(stack_name)
  return false unless stack

  return false unless stack.stack_status == "ROLLBACK_COMPLETE"

  # Finally check if all the minimal resources in the parent template have been deleted
  resp = cfn.describe_stack_resources(stack_name: stack_name)
  resource_statuses = resp.stack_resources.map(&:resource_status).uniq
  resource_statuses == ["DELETE_COMPLETE"]
end

#update_rollback_failed?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'lib/jets/cfn/stack/rollback.rb', line 24

def update_rollback_failed?
  stack = find_stack(stack_name)
  return false unless stack

  stack.stack_status == "UPDATE_ROLLBACK_FAILED"
end