set_desired_capacity ( $auto_scaling_group_name, $desired_capacity, $opt )

Adjusts the desired size of the AutoScalingGroup by initiating scaling activities. When reducing the size of the group, it is not possible to define which Amazon EC2 instances will be terminated. This applies to any Auto Scaling decisions that might result in terminating instances.

There are two common use cases for SetDesiredCapacity: one for users of the Auto Scaling triggering system, and another for developers who write their own triggering systems. Both use cases relate to the concept of cooldown.

In the first case, if you use the Auto Scaling triggering system, SetDesiredCapacity changes the size of your Auto Scaling group without regard to the cooldown period. This could be useful, for example, if Auto Scaling did something unexpected for some reason. If your cooldown period is 10 minutes, Auto Scaling would normally reject requests to change the size of the group for that entire 10-minute period. The SetDesiredCapacity command allows you to circumvent this restriction and change the size of the group before the end of the cooldown period.

In the second case, if you write your own triggering system, you can use SetDesiredCapacity to control the size of your Auto Scaling group. If you want the same cooldown functionality that Auto Scaling offers, you can configure SetDesiredCapacity to honor cooldown by setting the HonorCooldown parameter to true.

Access

public

Parameters

Parameter

Type

Required

Description

$auto_scaling_group_name

string

Required

The name of the Auto Scaling group. [Constraints: The value must be between 1 and 1600 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*]

$desired_capacity

integer

Required

The new capacity setting for the Auto Scaling group.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • HonorCooldown - boolean - Optional - By default, SetDesiredCapacity overrides any cooldown period. Set to True if you want Auto Scaling to reject this request when the Auto Scaling group is in cooldown.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Set the desired capacity for an autoscaling group.

// Instantiate the class
$as = new AmazonAS();

$response = $as->set_desired_capacity('my-scaling-group', 0, array(
	'HonorCooldown' => 'false'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/as.class.php | Toggle source view (8 lines) | View on GitHub

public function set_desired_capacity($auto_scaling_group_name, $desired_capacity, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['AutoScalingGroupName'] = $auto_scaling_group_name;
    $opt['DesiredCapacity'] = $desired_capacity;
    
    return $this->authenticate('SetDesiredCapacity', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback