put_scaling_policy ( $auto_scaling_group_name, $policy_name, $scaling_adjustment, $adjustment_type, $opt )
Creates or updates a policy for an Auto Scaling group. To update an existing policy, use the
existing policy name and set the parameter(s) you want to change. Any existing parameter not
changed in an update to an existing policy is not changed in this update request.
Access
Parameters
Parameter |
Type |
Required |
Description |
$auto_scaling_group_name
|
string
|
Required
|
The name or ARN 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]* ] |
$policy_name
|
string
|
Required
|
The name of the policy you want to create or update. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]* ] |
$scaling_adjustment
|
integer
|
Required
|
The number of instances by which to scale. AdjustmentType determines the interpretation of this number (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity. |
$adjustment_type
|
string
|
Required
|
Specifies whether the ScalingAdjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity , ExactCapacity , and PercentChangeInCapacity . [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]* ] |
$opt
|
array
|
Optional
|
An associative array of parameters that can have the following keys:
Cooldown - integer - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start.MinAdjustmentStep - integer - Optional - Used with AdjustmentType with the value PercentChangeInCapacity , the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least the number of instances specified in the value. You will get a ValidationError if you use MinAdjustmentStep on a policy with an AdjustmentType other than PercentChangeInCapacity .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
Examples
Create or update an autoscaling policy.
// Instantiate the class
$as = new AmazonAS();
$response = $as->put_scaling_policy('my-scaling-group', 'my-scaling-policy', 1, 'ChangeInCapacity', array(
'Cooldown' => 30,
));
// Success?
var_dump($response->isOK());
Result:
bool(true)
Related Methods
Source
Method defined in services/as.class.php | Toggle source view (10 lines) | View on GitHub
public function put_scaling_policy($auto_scaling_group_name, $policy_name, $scaling_adjustment, $adjustment_type, $opt = null)
{
if (!$opt) $opt = array();
$opt['AutoScalingGroupName'] = $auto_scaling_group_name;
$opt['PolicyName'] = $policy_name;
$opt['ScalingAdjustment'] = $scaling_adjustment;
$opt['AdjustmentType'] = $adjustment_type;
return $this->authenticate('PutScalingPolicy', $opt);
}