From 69a24411164c2af06f9c0ad28c067efa1f4bf69a Mon Sep 17 00:00:00 2001 From: darindeters Date: Tue, 14 Oct 2025 17:16:07 -0700 Subject: [PATCH 1/2] Align schedules with Pacific Time timezone support --- README.md | 2 +- ec2-dynamic-scheduler.yaml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 28b1c31..da0d984 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ To deploy with AWS Console: ## 📝 Customization - **Resize Target:** The off-hours instance type defaults to `t3.medium`. You can change this in the Lambda code. -- **Schedule:** Default schedule is hardcoded for Pacific Time. You can update the EventBridge cron rules if needed. +- **Schedule:** Default EventBridge cron rules are pinned to 4 AM and 7 PM Pacific (with automatic DST handling via `ScheduleExpressionTimezone: America/Los_Angeles`). Update the `LambdaScheduleUpTime`/`LambdaScheduleDownTime` parameters if you need different windows. - **Logging:** CloudWatch Log Group is created with 14-day retention. Logs show success and error messages per instance. ## 🧪 Testing diff --git a/ec2-dynamic-scheduler.yaml b/ec2-dynamic-scheduler.yaml index 1cea999..df51776 100644 --- a/ec2-dynamic-scheduler.yaml +++ b/ec2-dynamic-scheduler.yaml @@ -7,10 +7,10 @@ Parameters: Default: DynamicEC2Scheduler LambdaScheduleUpTime: Type: String - Default: "cron(0 11 ? * MON-FRI *)" + Default: "cron(0 4 ? * MON-FRI *)" LambdaScheduleDownTime: Type: String - Default: "cron(0 2 ? * MON-FRI *)" + Default: "cron(0 19 ? * MON-FRI *)" Resources: @@ -172,6 +172,7 @@ Resources: Name: EC2ScalerScheduleDown Description: Triggers Lambda to scale down EC2 instances at 7 PM Pacific, Monday through Friday ScheduleExpression: !Ref LambdaScheduleDownTime + ScheduleExpressionTimezone: America/Los_Angeles State: ENABLED Targets: - Arn: !GetAtt EC2ScalerFunction.Arn @@ -185,6 +186,7 @@ Resources: Name: EC2ScalerScheduleUp Description: Triggers Lambda to scale up EC2 instances at 4 AM Pacific, Monday through Friday ScheduleExpression: !Ref LambdaScheduleUpTime + ScheduleExpressionTimezone: America/Los_Angeles State: ENABLED Targets: - Arn: !GetAtt EC2ScalerFunction.Arn From f58fd6b2ea6f42620aa208a5fa6adf99f1aacbe1 Mon Sep 17 00:00:00 2001 From: darindeters Date: Wed, 15 Oct 2025 09:24:14 -0700 Subject: [PATCH 2/2] Clarify schedule documentation --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da0d984..66cbf95 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This AWS CloudFormation stack resizes EC2 instances on a schedule to optimize co ## 🔧 How It Works - A Lambda function runs twice per day via EventBridge rules: - - **7 PM Pacific** — Scales down tagged instances to a smaller type (e.g. `t3.medium`) + - **7 PM Pacific (Mon–Fri only)** — Scales down tagged instances to a smaller type (e.g. `t3.medium`) - **4 AM Pacific (Mon–Fri only)** — Scales them back up to the original size - Instances are rebooted once per resize operation (stop → modify → start) - This works even if you're using Compute Savings Plans @@ -45,6 +45,7 @@ To deploy with AWS Console: - **Resize Target:** The off-hours instance type defaults to `t3.medium`. You can change this in the Lambda code. - **Schedule:** Default EventBridge cron rules are pinned to 4 AM and 7 PM Pacific (with automatic DST handling via `ScheduleExpressionTimezone: America/Los_Angeles`). Update the `LambdaScheduleUpTime`/`LambdaScheduleDownTime` parameters if you need different windows. +- **Redeployment:** Deploy or update the CloudFormation stack after changing schedule parameters so the EventBridge rules pick up the new cron expressions and timezone. - **Logging:** CloudWatch Log Group is created with 14-day retention. Logs show success and error messages per instance. ## 🧪 Testing