Skip to content

Instantly share code, notes, and snippets.

@cyhsutw
Last active February 11, 2024 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cyhsutw/97a97da04cd1bb1a458331bf2c5c018d to your computer and use it in GitHub Desktop.
Save cyhsutw/97a97da04cd1bb1a458331bf2c5c018d to your computer and use it in GitHub Desktop.
Stop Sidekiq and complete Lifecycle hooks using AWS Systems Manager Automation - https://grass-fed.engineer/2021/10/24/tracing-down-lost-sidekiq-jobs/
description: Gracefully stop sidekiq and complete lifecycle hook action
schemaVersion: "0.3"
assumeRole: "{{ role }}"
parameters:
role:
description: ARN of the role for execution
type: String
autoscalingGroupName:
type: String
instanceId:
type: String
lifecycleHookName:
type: String
mainSteps:
- inputs:
Parameters:
executionTimeout: "120"
commands:
- sudo systemctl stop sidekiq
InstanceIds:
- "{{ instanceId }}"
DocumentName: AWS-RunShellScript
name: StopSidekiq
action: aws:runCommand
- inputs:
LifecycleHookName: "{{ lifecycleHookName }}"
InstanceId: "{{ instanceId }}"
AutoScalingGroupName: "{{ autoscalingGroupName }}"
Service: autoscaling
Api: CompleteLifecycleAction
LifecycleActionResult: CONTINUE
name: CompleteTerminationProcess
action: aws:executeAwsApi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment