Skip to content

put_scheduled_update_group_action async

put_scheduled_update_group_action(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    scheduled_action_name: Optional[XmlStringMaxLen255] = None,
    time: Optional[TimestampType] = None,
    start_time: Optional[TimestampType] = None,
    end_time: Optional[TimestampType] = None,
    recurrence: Optional[XmlStringMaxLen255] = None,
    min_size: Optional[AutoScalingGroupMinSize] = None,
    max_size: Optional[AutoScalingGroupMaxSize] = None,
    desired_capacity: Optional[AutoScalingGroupDesiredCapacity] = None,
    time_zone: Optional[XmlStringMaxLen255] = None,
) -> None

Creates or updates a scheduled scaling action for an Auto Scaling group.

For more information, see Scheduled scaling in the Amazon EC2 Auto Scaling User Guide.

You can view the scheduled actions for an Auto Scaling group using the DescribeScheduledActions API call. If you are no longer using a scheduled action, you can delete it by calling the DeleteScheduledAction API.

If you try to schedule your action in the past, Amazon EC2 Auto Scaling returns an error message.

Parameters:

  • auto_scaling_group_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the Auto Scaling group.

  • scheduled_action_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of this scaling action.

  • time (Optional[TimestampType], default: None ) –

    This property is no longer used.

  • start_time (Optional[TimestampType], default: None ) –

    The date and time for this action to start, in YYYY-MM-DDThh:mm:ssZ format in UTC/GMT only and in quotes (for example, "2021-06-01T00:00:00Z").

    If you specify Recurrence and StartTime, Amazon EC2 Auto Scaling performs the action at this time, and then performs the action based on the specified recurrence.

  • end_time (Optional[TimestampType], default: None ) –

    The date and time for the recurring schedule to end, in UTC. For example, "2021-06-01T00:00:00Z".

  • recurrence (Optional[XmlStringMaxLen255], default: None ) –

    The recurring schedule for this action. This format consists of five fields separated by white spaces: [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]. The value must be in quotes (for example, "30 0 1 1,6,12 *"). For more information about this format, see Crontab.

    When StartTime and EndTime are specified with Recurrence, they form the boundaries of when the recurring action starts and stops.

    Cron expressions use Universal Coordinated Time (UTC) by default.

  • min_size (Optional[AutoScalingGroupMinSize], default: None ) –

    The minimum size of the Auto Scaling group.

  • max_size (Optional[AutoScalingGroupMaxSize], default: None ) –

    The maximum size of the Auto Scaling group.

  • desired_capacity (Optional[AutoScalingGroupDesiredCapacity], default: None ) –

    The desired capacity is the initial capacity of the Auto Scaling group after the scheduled action runs and the capacity it attempts to maintain. It can scale beyond this capacity if you add more scaling conditions.

    You must specify at least one of the following properties: MaxSize, MinSize, or DesiredCapacity.

  • time_zone (Optional[XmlStringMaxLen255], default: None ) –

    Specifies the time zone for a cron expression. If a time zone is not provided, UTC is used by default.

    Valid values are the canonical names of the IANA time zones, derived from the IANA Time Zone Database (such as Etc/GMT+9 or Pacific/Tahiti). For more information, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

Raises:

  • AlreadyExistsFault –

    You already have an Auto Scaling group or launch configuration with this name.

  • LimitExceededFault –

    You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see DescribeAccountLimits in the Amazon EC2 Auto Scaling API Reference.

  • ResourceContentionFault –

    You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To add a scheduled action to an Auto Scaling group This example adds the specified scheduled action to the specified Auto Scaling group.

>>> await client.put_scheduled_update_group_action(auto_scaling_group_name='my-auto-scaling-group', scheduled_action_name='my-scheduled-action', start_time='2014-05-12T08:00:00Z', end_time='2014-05-12T08:00:00Z', min_size=2, max_size=6, desired_capacity=4)
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
async def put_scheduled_update_group_action(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    scheduled_action_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    time: Optional["capo_auto_scaling.types.timestamp_type.TimestampType"] = None,
    start_time: Optional[
        "capo_auto_scaling.types.timestamp_type.TimestampType"
    ] = None,
    end_time: Optional[
        "capo_auto_scaling.types.timestamp_type.TimestampType"
    ] = None,
    recurrence: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    min_size: Optional[
        "capo_auto_scaling.types.auto_scaling_group_min_size.AutoScalingGroupMinSize"
    ] = None,
    max_size: Optional[
        "capo_auto_scaling.types.auto_scaling_group_max_size.AutoScalingGroupMaxSize"
    ] = None,
    desired_capacity: Optional[
        "capo_auto_scaling.types.auto_scaling_group_desired_capacity.AutoScalingGroupDesiredCapacity"
    ] = None,
    time_zone: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
) -> None:
    """<p>Creates or updates a scheduled scaling action for an Auto Scaling group.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scheduled-scaling.html">Scheduled scaling</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <p>You can view the scheduled actions for an Auto Scaling group using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeScheduledActions.html">DescribeScheduledActions</a> API call. If you are no longer using a scheduled action, you can delete it by calling the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DeleteScheduledAction.html">DeleteScheduledAction</a> API.</p> <p>If you try to schedule your action in the past, Amazon EC2 Auto Scaling returns an error message.</p>

    Args:
        auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
        scheduled_action_name: <p>The name of this scaling action.</p>
        time: <p>This property is no longer used.</p>
        start_time: <p>The date and time for this action to start, in YYYY-MM-DDThh:mm:ssZ format in UTC/GMT only and in quotes (for example, <code>"2021-06-01T00:00:00Z"</code>).</p> <p>If you specify <code>Recurrence</code> and <code>StartTime</code>, Amazon EC2 Auto Scaling performs the action at this time, and then performs the action based on the specified recurrence.</p>
        end_time: <p>The date and time for the recurring schedule to end, in UTC. For example, <code>"2021-06-01T00:00:00Z"</code>.</p>
        recurrence: <p>The recurring schedule for this action. This format consists of five fields separated by white spaces: [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]. The value must be in quotes (for example, <code>"30 0 1 1,6,12 *"</code>). For more information about this format, see <a href="http://crontab.org">Crontab</a>.</p> <p>When <code>StartTime</code> and <code>EndTime</code> are specified with <code>Recurrence</code>, they form the boundaries of when the recurring action starts and stops.</p> <p>Cron expressions use Universal Coordinated Time (UTC) by default.</p>
        min_size: <p>The minimum size of the Auto Scaling group.</p>
        max_size: <p>The maximum size of the Auto Scaling group.</p>
        desired_capacity: <p>The desired capacity is the initial capacity of the Auto Scaling group after the scheduled action runs and the capacity it attempts to maintain. It can scale beyond this capacity if you add more scaling conditions. </p> <note> <p>You must specify at least one of the following properties: <code>MaxSize</code>, <code>MinSize</code>, or <code>DesiredCapacity</code>. </p> </note>
        time_zone: <p>Specifies the time zone for a cron expression. If a time zone is not provided, UTC is used by default. </p> <p>Valid values are the canonical names of the IANA time zones, derived from the IANA Time Zone Database (such as <code>Etc/GMT+9</code> or <code>Pacific/Tahiti</code>). For more information, see <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">https://en.wikipedia.org/wiki/List_of_tz_database_time_zones</a>.</p>

    Raises:
        capo_auto_scaling.errors.already_exists_fault.AlreadyExistsFault: <p>You already have an Auto Scaling group or launch configuration with this name.</p>
        capo_auto_scaling.errors.limit_exceeded_fault.LimitExceededFault: <p>You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeAccountLimits.html">DescribeAccountLimits</a> in the <i>Amazon EC2 Auto Scaling API Reference</i>.</p>
        capo_auto_scaling.errors.resource_contention_fault.ResourceContentionFault: <p>You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To add a scheduled action to an Auto Scaling group
        This example adds the specified scheduled action to the specified Auto Scaling group.

        >>> await client.put_scheduled_update_group_action(auto_scaling_group_name='my-auto-scaling-group', scheduled_action_name='my-scheduled-action', start_time='2014-05-12T08:00:00Z', end_time='2014-05-12T08:00:00Z', min_size=2, max_size=6, desired_capacity=4)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.put_scheduled_update_group_action_type.PutScheduledUpdateGroupActionType]",
    ) -> AsyncOperationResponse[None]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.put_scheduled_update_group_action

        (
            output,
            http_response,
        ) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.put_scheduled_update_group_action.async_put_scheduled_update_group_action(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutScheduledUpdateGroupAction")
    )
    input_: capo_auto_scaling.types.put_scheduled_update_group_action_type.PutScheduledUpdateGroupActionType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if scheduled_action_name is not None:
        input_["scheduled_action_name"] = scheduled_action_name
    if time is not None:
        input_["time"] = time
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if recurrence is not None:
        input_["recurrence"] = recurrence
    if min_size is not None:
        input_["min_size"] = min_size
    if max_size is not None:
        input_["max_size"] = max_size
    if desired_capacity is not None:
        input_["desired_capacity"] = desired_capacity
    if time_zone is not None:
        input_["time_zone"] = time_zone

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output