Skip to content

Instantly share code, notes, and snippets.

View channaveer's full-sized avatar

Channaveer Hakari channaveer

View GitHub Profile
@channaveer
channaveer / aws_autoscaling_cron.rb
Created October 2, 2023 01:06 — forked from kixorz/aws_autoscaling_cron.rb
Running cron jobs in AWS Auto Scaling group is tricky. When you deploy the same code and configuration to all instances in the group, cron job would run on all of them. You may not want that. This script detects the first instance in the group and allows only this instance to run the job. IAM user used by this script needs to have permissions to…
#!/usr/bin/env ruby
require 'syslog'
require 'net/http'
require 'aws-sdk'
Syslog.open
AWS.config({
:access_key_id => '<iam user key>',
:secret_access_key => '<iam user secret>'