Skip to content

Instantly share code, notes, and snippets.

@sorentwo
Created March 19, 2023 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorentwo/ba4a07d3a011d212c19a5bb775a6c536 to your computer and use it in GitHub Desktop.
Save sorentwo/ba4a07d3a011d212c19a5bb775a6c536 to your computer and use it in GitHub Desktop.
EC2 ASG Cloud for Oban Auto Scaling
defmodule Oban.Pro.Clouds.EC2ASG do
@behaviour Oban.Pro.Cloud
@impl Oban.Pro.Cloud
def init(opts), do: Map.new(opts)
@impl Oban.Pro.Cloud
def scale(desired, conf) do
params = %{
"Action" => "SetDesiredCapacity",
"AutoScalingGroupName" => conf.asg,
"DesiredCapacity" => desired,
"Version" => "2011-01-01"
}
ExAws.request(%ExAws.Operation.Query{
path: "",
params: params,
service: :autoscaling,
action: :set_desired_capacity
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment