0

I'm trying to suspend ASG processes during a CodePipeline deployment using the Ruby SDK. I can get the AutoScaling Client but I can't seem to be able to convert that group to an object.

client = Aws::AutoScaling::Client.new
asg = client.describe_auto_scaling_groups({auto_scaling_group_names:['MyASG']})[:auto_scaling_groups].first

asg.suspend_processes({scaling_processes:['AZRebalance','AlarmNotification']})

I get the auto-scaling group that I want to work with but when I try to call a function on it, I get this error:

undefined method `restore_processes' for #<Aws::AutoScaling::Types::AutoScalingGroup:0x00007fa3e18f8b30>

I understand why I'm getting the error (asg is a 'Type' and not an object) but I don't know how to turn it into an object. I know I'm missing something silly but I just don't know what it is.

Richard Hurt
  • 2,049
  • 24
  • 32

1 Answers1

0

I figured out the answer: use a Resource Interface instead of trying to use the Client.

Apparently, each AWS resource has a Client object as well as a Resource interface in the SDK. Resource interfaces are object oriented classes that represent actual resources in AWS. They are built on top of API clients and provide additional functionality.

So, this is what my code looks like now:

asg   = Aws::AutoScaling::Resource.new
group = asg.group('MyASG')
group.suspend_processes({scaling_processes:['AZRebalance','AlarmNotification']})

It's more simple and straightforward and is easier to read too.

Richard Hurt
  • 2,049
  • 24
  • 32