There is an ongoing outage on the primary CPAN mirror. It is possible to work around the issue by using MetaCPAN as a mirror.

parse_scheduled_action

my $action_hash = $self->parse_scheduled_action( $scheduled_action_hash );

This is a private helper subroutine that acts as the primary parser and validator for the user-defined schedule configuration. It takes a single, user-configured schedule hash (e.g., the business_hours block) and translates it into a complex data structure containing the two distinct, API-ready "ScaleOut" and "ScaleIn" actions required by AWS.

The subroutine's main responsibilities are:

  • Parsing: It parses the user-friendly start_time, end_time, days, min_capacity, and max_capacity values. It supports flexible delimiters for capacity pairs and both textual and numeric day representations.

  • Validation: It performs a series of critical, upfront validation checks. If any part of the configuration is missing, malformed, or logically inconsistent (e.g., a scale-in capacity is larger than a scale-out capacity), the subroutine will abort the entire process with a clear, descriptive error message.

  • Transformation: It transforms the validated user input into two separate, syntactically correct AWS cron expressions (cron(...)) for the scale-out and scale-in events.

  • Structuring: It builds and returns a nested hash that precisely mirrors the data structure needed for the put-scheduled-action API calls, separating the ScaleOut and ScaleIn actions, each with their own Schedule string and Action hash containing the corresponding capacity limits.

Arguments

  • $scheduled_action

    A hash reference corresponding to a single named schedule from the user's YAML configuration. It is expected to contain the following keys:

    • start_time (e.g., "09:00")

    • end_time (e.g., "17:00")

    • days (e.g., "MON-FRI", "2-6")

    • min_capacity (e.g., "2/1", "2-1")

    • max_capacity (e.g., "4/1", "4-1")

Returns

A hash reference containing two keys, ScaleOut and ScaleIn. Each of these keys contains another hash with the fully-formed Action and Schedule sub-hashes required for the final API calls.