Auto Scaling examples using SDK for Ruby
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for Ruby with Auto Scaling.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Get started
The following code examples show how to get started using Auto Scaling.
- SDK for Ruby
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. require 'aws-sdk-autoscaling' require 'logger' # AutoScalingManager is a class responsible for managing AWS Auto Scaling operations # such as listing all Auto Scaling groups in the current AWS account. class AutoScalingManager def initialize(client) @client = client @logger = Logger.new($stdout) end # Gets and prints a list of Auto Scaling groups for the account. def list_auto_scaling_groups paginator = @client.describe_auto_scaling_groups auto_scaling_groups = [] paginator.each_page do |page| auto_scaling_groups.concat(page.auto_scaling_groups) end if auto_scaling_groups.empty? @logger.info('No Auto Scaling groups found for this account.') else auto_scaling_groups.each do |group| @logger.info("Auto Scaling group name: #{group.auto_scaling_group_name}") @logger.info(" Group ARN: #{group.auto_scaling_group_arn}") @logger.info(" Min/max/desired: #{group.min_size}/#{group.max_size}/#{group.desired_capacity}") @logger.info("\n") end end end end if $PROGRAM_NAME == __FILE__ autoscaling_client = Aws::AutoScaling::Client.new manager = AutoScalingManager.new(autoscaling_client) manager.list_auto_scaling_groups end
-
For API details, see DescribeAutoScalingGroups in AWS SDK for Ruby API Reference.
-