Git Product home page Git Product logo

instance-scheduler-on-aws's Introduction

Instance Scheduler on AWS

The Instance Scheduler on AWS solution automates the starting and stopping of Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) instances.

This solution helps reduce operational costs by stopping resources that are not in use and starting them when they are needed. The cost savings can be significant if you leave all of your instances running at full utilization continuously.

Getting Started

To understand how to use Instance Scheduler on AWS, please review the implementation guide on the solution landing page. To deploy the solution, see Deploying the Solution.

Repository Organization

|- .github/                       - GitHub issue and pull request templates
|- .projen/                       - projen-generated project metadata
|- deployment/                    - build scripts
|- projenrc/                      - projen source code
|- source/                        - project source code
  |- app/                         - AWS Lambda Function source code
  |- cli/                         - Instance Scheduler CLI source code
  |- instance-scheduler/          - CDK source code
  |- pipeline/                    - automated testing pipeline source code

Deploying the Solution

One-Click Deploy From Amazon Web Services

Refer to the solution landing page to deploy Instance Scheduler on AWS using our pre-packaged deployment assets.

Deploy from source code using CDK

Instance Scheduler can be deployed to your AWS account directly from the source code using AWS Cloud Development Kit (CDK).

Prerequisites

  • cloned repository
  • AWS CLI v2
  • Node.JS 18
  • docker

Deploying the hub stack

npm ci
npx cdk bootstrap
npx cdk deploy instance-scheduler-on-aws

This will deploy the solution into your aws account using all default configuration settings. You will then need to update those settings to their desired values from the CloudFormation console by selecting the deployed template and clicking "Update" -> "Use Current Template".

Refer to the Implementation Guide for guidance on what each of the configuration parameters is for.

Deploying Remote Stacks in Other Accounts

To deploy the remote stack for cross-account scheduling, you will first need to have deployed the primary control stack. Then update your aws credentials to match those of the remote account you would like to schedule and deploy the remote stack.

npx cdk bootstrap
npx cdk deploy instance-scheduler-on-aws-remote --parameters InstanceSchedulerAccount={account-id} --parameters Namespace={namespace} --parameters UsingAWSOrganizations={useOrgs}

Replace:

  • {account-id} with the id of the account that contains the primary control stack.
  • {namespace} with the same unique namespace that was provided to the primary control stack
  • {useOrgs} with the same value set in the primary control stack (Yes/No)

For example: InstanceSchedulerAccount=111222333444

Deploy from GitHub (AWS Console)

This method mimics the procedure used by AWS One-Click Deploy allowing you to deploy the solution from the AWS console using assets that you can control and update.

Overview

AWS Solutions use two buckets: a bucket for global access to templates, which is accessed via HTTPS, and regional buckets for access to assets within the region, such as Lambda code. You will need:

  • One global bucket that is accessed via the https end point. AWS CloudFormation templates are stored here. Ex. "mybucket"
  • One regional bucket for each region where you plan to deploy using the name of the global bucket as the root, and suffixed with the region name. Ex. "mybucket-us-east-1"
  • Your buckets should be encrypted and disallow public access.

You will need:

  • cloned repository
  • AWS CLI v2
  • Node.js 18
  • docker
  • Two S3 buckets (minimum): 1 global and 1 for each region where you will deploy.

Step 1 - Download from GitHub

Clone the repository to a local directory on your linux client. Note: If you intend to modify Instance Scheduler you may wish to create your own fork of the GitHub repo and work from that. This allows you to check in any changes you make to your private copy of the solution.

Step 2 - Build the solution

From the deployment folder in your cloned repo, run build-s3-dist.sh, passing the root name of your bucket(ex. mybucket), name of the solution (i.e. instance-scheduler-on-aws) and the version you are building (ex. v1.5.0). We recommend using a similar version based on the version downloaded from GitHub (ex. GitHub: v1.5.0, your build: v1.5.0.mybuild).

cd deployment
./build-s3-dist.sh <bucketname> instance-scheduler-on-aws <version>

Step 3 - Upload to your buckets

The previous step will have generated several folders in your local directory including:

deployment/global-s3-assets
deployment/regional-s3-assets

Upload the contents of deployment/global-s3-assets to your global bucket and deployment/regional-s3-assets to your regional buckets following the pattern s3://<bucket-name>/<solution-name>/<version>/<asset>.

For example:

//global assets
s3://mybucket/instance-scheduler-on-aws/v1.5.0/instance-scheduler.template
s3://mybucket/instance-scheduler-on-aws/v1.5.0/instance-scheduler-remote.template

//regional assets
s3://mybucket-us-east-1/instance-scheduler-on-aws/v1.5.0/f779f5b7643ba70e9a5e25c8898f4e4e8e54ca15b150eee1dd25c2c636b188b8.zip
s3://mybucket-us-west-1/instance-scheduler-on-aws/v1.5.0/f779f5b7643ba70e9a5e25c8898f4e4e8e54ca15b150eee1dd25c2c636b188b8.zip

Note: The scheduler-cli is optional and does not need to be published to the global bucket for deploy to work.

Step 4 - Deploy The Solution

Refer to the Implementation Guide for deployment instructions, using the link to the instance-scheduler.template from your bucket, rather than the one for AWS Solutions. Ex. https://mybucket.s3.amazonaws.com/instance-scheduler-on-aws/v1.5.0.mybuild/instance-scheduler.template

Testing the Solution

Prerequisites

  • cloned repository
  • AWS CLI v2
  • Node.js 18
  • docker
  • Python 3.10
  • tox

Running Tests Locally

npm ci
npm run test

Automated Testing Pipeline

Instance Scheduler on AWS includes an optional automated testing pipeline that can be deployed to automatically test any changes you develop for the solution on your own development fork. Once setup, this pipeline will automatically download, build, and test any changes that you push to a specified branch on your development fork.

The pipeline can be configured to automatically watch and pull from repos hosted on either AWS CodeCommit or GitHub.

Prerequisites

  • AWS account
  • repository fork
  • AWS CLI v2
  • Node.js 18
  • docker

Step 0 (If Using GitHub) - Connect CodeStar to Your GitHub Account

For the pipeline to be able to test your changes, you must provide permission to access your development repo.

https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html

Note: CodeStar only needs access to your Instance Scheduler development fork, it does not need access to all repositories.

Once the connection has been set up, make sure you save the connection ARN for the next step.

Step 1 - Prepare Your Environment

In your local environment, first install all necessary dependencies and bootstrap your account for CDK deployment.

npm ci
npx cdk bootstrap

Step 2 - Deploy the testing pipeline bootstrap stack

npx cdk deploy instance-scheduler-on-aws-testing-pipeline-bootstrap

Once the stack is deployed, Go to CloudFormation and update the bootstrap stack with the configuration your pipeline should use

At a minimum you must provide:

  • repoName -- the name of your forked repo (either in CodeCommit or GitHub)
  • repoBranch -- The branch in your fork that should be watched and pulled from for testing

if sourcing from GitHub instead of CodeCommit, you must also provide:

  • codestarArn -- the CodeStar connection ARN from the previous step
  • repoArn -- the GitHub owner of your fork

For example, if your GitHub username is "myUser" and you would like to test changes pushed to the develop branch of your fork the values you would need to set would be:

arn = {arn from Step 0}
owner = myUser
repo = instance-scheduler-on-aws
branch = develop

Step 3 - Deploy the Testing Pipeline

# source from CodeCommit
npx cdk deploy instance-scheduler-on-aws-testing-pipeline --context instance-scheduler-on-aws-pipeline-source=codecommit

# source from GitHub
npx cdk deploy instance-scheduler-on-aws-testing-pipeline --context instance-scheduler-on-aws-pipeline-source=codestar

note: If you do not provide a context, the pipeline will default to using codecommit.

This will deploy the automated testing pipeline into your AWS account which will then begin running tests against your development fork automatically.

To view the results. Go to CodePipeline and click on the pipeline that begins with instance-scheduler-on-aws-testing-pipeline.

Modifying the Solution

projen

This solution uses projen to manage certain project files. If you need to modify any of these files, modify the source in .projenrc.ts and run projen to regenerate the files.

Package installation

# For Node.js dependencies
npm ci

# For Python dependencies
cd source/app
poetry install

If you don't have poetry, refer to Poetry to install poetry.

CDK Documentation

Instance Scheduler on AWS templates are generated using AWS CDK, for further information on CDK please refer to the documentation.

Collection of Operational Metrics

This solution collects anonymized operational metrics to help AWS improve the quality and features of the solution. For more information, including how to disable this capability, please see the implementation guide.


Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/

or in the "LICENSE" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.

instance-scheduler-on-aws's People

Contributors

aijunpeng avatar aws-khargita avatar aws-solutions-github-bot avatar crypticcabub avatar georgebearden avatar gockle avatar hearde avatar jpeddicord avatar shsenior avatar tbelmega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instance-scheduler-on-aws's Issues

Stack failing to deploy

Hello,
While trying to deploy the aws instance scheduler, it fails to create the Custom:ServiceSetup. In the log group created within this template, it shows the following errors:

2018-05-24 - 09:17:14.878 - INFO : Handler SchedulerSetupHandler : Received request
{
"StackId": "arn:aws:cloudformation:us-east-1:601468343342:stack/n0252813-instance-scheduler-development/0c6693a0-5f33-11e8-9880-503acac5c099",
"ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A601468343342%3Astack/n0252813-instance-scheduler-development/0c6693a0-5f33-11e8-9880-503acac5c099%7CSchedulerConfigHelper%7Cb8705de7-de4a-4a1f-a3ba-f425360eebda?AWSAccessKeyId=AKIAIEJT6TT2H5EX7LPA&Expires=1527160634&Signature=0XhvDWy3BO%2FbWeTqp5P%2FVzTlyDQ%3D",
"ResourceProperties": {
"stack_version": "2.2.2.0",
"stopped_tags": "",
"trace": "True",
"use_metrics": "False",
"started_tags": "",
"schedule_lambda_account": "True",
"config_table": "n0252813-instance-scheduler-development-ConfigTable-1DESQ99IZSP2E",
"ServiceToken": "arn:aws:lambda:us-east-1:601468343342:function:n0252813-instance-scheduler-development-InstanceSchedulerMain",
"scheduled_services": [
"ec2",
"rds"
],
"default_timezone": "Europe/London",
"regions": [
"us-east-1",
"eu-west-1"
],
"timeout": "120",
"log_retention_days": "30",
"tagname": "Schedule",
"cross_account_roles": [
"arn:aws:iam::601468343342:role/cloud-services/lm-cross-account-n0252813-instance-scheduler"
]
},
"RequestType": "Create",
"ServiceToken": "arn:aws:lambda:us-east-1:601468343342:function:n0252813-instance-scheduler-development-InstanceSchedulerMain",
"ResourceType": "Custom::ServiceSetup",
"RequestId": "b8705de7-de4a-4a1f-a3ba-f425360eebda",
"LogicalResourceId": "SchedulerConfigHelper"
}

2018-05-24 - 09:17:18.151 - ERROR : Error creating sample schedules and periods unpack requires a string argument of length 328875
2018-05-24 - 09:17:20.150 - INFO : Error setting scheduler configuration unpack requires a string argument of length 525483

Can you provide insight into what this error means?

Thanks,
Aoife

Ensure Stop - Question/Feature Request

Is there a way to ensure an instance is stopped, regardless of what state it's in and overriding manual state changes?
Our use case for this is stopping a test server in the evening, after everyone will have finished working on it. This server may or may not be needed on any given day, so starting it up must be manual, but we want to ensure it is stopped, after work, without relying on the users to remember.

Sorry if this is the wrong place to ask this sort of question, if so, could you please point me to the correct forum.

Thanks,

Richard

EC2 Instance not starting - no errors

Scheduler doesnt seem to be starting EC2 instance in us-east-1. Shutdown of EC2 works fine and RDS start/stop work fine as well.
Looking at the logs, everything appears ok (there are no error) and logs indicate that EC2 instance was started. However, if i check instance in console it shows as "stopped". I've attached actual log output from this morning and obfuscated actual account # and instance id below.
ec2-scheduler-log.txt

Editing the DynamoDB in Cloudformation Launch.

Hi,

I see that the DynamoDB is filled by this part of the code

"Settings": {
            "Metrics": {
                "Url": "https://metrics.awssolutionsbuilder.com/generic",
                "SolutionId": "S00030"
            },

But i exactly would like to edit this part, is there any option to do so?
So it will choice a different URL but with the same info.

Regards,

Enable Maintenance window option for "Instance scheduler" and understand its behavior.

Hi,

I wanted to enable Maintenance Window option for Instance Scheduler.

  1. Can you help me with the API for this. "use_maintenance_window" used as an attribute in the custom service ('Custom::ServiceInstanceSchedule') properties giving error. Please correct me with the correct attribute.
    ex:
    OfficeChicagoTimeZone7PMto7AM:
    Type: 'Custom::ServiceInstanceSchedule'
    Properties:
    Description: Working Hours in Chicago
    ServiceToken: >-
    ****************************************************************************_main
    Enforced: 'False'
    Timezone: America/Chicago
    use_maintenance_window: 'True'
    Periods:
    - Description: Hours in weekdays and weekends
    BeginTime: '07:00'
    EndTime: '19:00'
    WeekDays: Mon-Sun

  2. What if the maintenance for the RDS instances goes beyond the Maintenance Window time. Will the scheduler wait until the Maintenance is complete or will it stops the instance based on the timings of the maintenance window.

Instances behind ASG

Is it possible to de-attach and re-attach instances are behind ASG based on scheduled action?

AWS Instance Scheduler Cross-account

Hi,

i follow these steps to deploy the solution,
https://docs.aws.amazon.com/solutions/latest/instance-scheduler/deployment.html
and it works fine for the same account (AAAAAAAA) but when i try to extend the scheduler to a secondary account (BBBBBBBBBB) i always get the following error from Cloud Watch,

ERROR : Can not assume role arn:aws:iam::BBBBBBBBBB:role/EMCSTemp-EC2SchedulerCrossAccountRole-1A751JI9G9V1Y for account BBBBBBBBBB, (An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::AAAAAAAA:assumed-role/EMCSTemp-SchedulerRole-1ESJBRLZ26VKA/EMCSTemp-InstanceSchedulerMain is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::BBBBBBBBBB:role/EMCSTemp-EC2SchedulerCrossAccountRole-1A751JI9G9V1Y))

StackName: EMCSTemp

I also added this inline policy in the user's group:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1520691087000",
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::BBBBBBBBBB:role/EMCSTemp-EC2SchedulerCrossAccountRole-1A751JI9G9V1Y","arn:aws:sts::AAAAAAAA:assumed-role/EMCSTemp-SchedulerRole-1ESJBRLZ26VKA/EMCSTemp-InstanceSchedulerMain"
]
}
]
}

But still the same error. Any idea?

Thanks in advance.

Alberto

use_metrics

While troubleshooting why the custom metrics have not been created, I found out that when use_metrics is not set on the schedule level (left undefined), the value set on the global config level will be ignored and no custom metrics will be created (even if it set to true on the global config level). Wanted to check if this was the intention.

I don't believe that it's supposed to be like that since it means that:

  1. In order to enable custom metrics, it must be configured on the schedule level (irrespective of the setting on the global config level).
  2. The setting of use_metrics on the global config level doesn't have any effect.

PS I really like AWS Instance Scheduler!

Optional Arguments

Hi,
Thanks for the awesome tool. I need to schedule very specific periods, day, month, & times, however the "scheduler-cli create-period" does NOT support --months, like the documentation states: https://docs.aws.amazon.com/solutions/latest/instance-scheduler/components.html

I receive the following error: scheduler-cli: error: unrecognized arguments: --months 4

Performing a "help" -h on the command indeed does not list --months.

Will this option become available, as it would be most helpful?

optional arguments:
-h, --help show this help message and exit
--begintime BEGINTIME
Begin time of the period in hotmat hh:mm
--description DESCRIPTION
Description for the period
--endtime ENDTIME End time of the period in format hh:mm
--monthdays MONTHDAYS
Calendar monthdays of the period
--name NAME Name of the period
--weekdays WEEKDAYS Weekdays of the period
--query QUERY JMESPath query to transform or filter the result
--region REGION Region in which the Instance Scheduler stack is
deployed
--stack STACK, -s STACK
Name of the Instance Scheduler stack

Thanks
Darren

AWS Instance Scheduler not working in local mode

Hi,

I am trying to execute the instance scheduler locally by python run_scheduler_local.py Test-Instance-Scheduler.
It executes for a bit but it gives a error after a couple of seconds.
Error: ModuleNotFoundError: No module named 'instance_states'
But as I can see module is available in the code.

Any suggestion for remediation of error and how to run it locally?

Custom Resource

Hello,
If I try to deploy the custom resource that aws provides in the aws instance scheduler into the same account the main instance schedule stack is deployed, it deploys successfully and i can create new schedules/periods.

However, if I try to deploy the custom resource into an account that doesnt have the main instance scheduler stack deployed, it fails and complains about permissions on the lambda. For example:

User: arn:aws:sts::876481310196:assumed-role// is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:us-east-1:601468343342:function:n0252813-instance-scheduler-dev-InstanceSchedulerMain

Is there a way of being to allow any user in any other account to invoke this lambda so that I can create custom resources in other accounts.

override_status

setting override_status is not clear on usage or not working with a cloudformation schedules.

I am adding in schedules/periods via cloudformation. I recently have come to the need of using override_status but whenever override_status is used the change set will fail. I think i found a work around by just not setting a start time for the period that is attached to the schedule and not adding override_status but it would be nice to know how to use, but even after re-reviewing the the document i am not seeing any more detail about how override status should work.

Nightly period

Hi to everyone.

I have some instances that must be up during night and stopped during the day.
For example, an instance that must start art 19.00 and stop at 10.00. I tried with:

begintime 19:00
endtime 10:00
It doesn't works, beginperiod must be lower than endtime

1st period
begintime 19:00
endtime 00:00

2nd period
begintime 00:00
endtime 10:00
Doesn't works too. Only the 2nd period is working, the 1st is ignored.

Maybe anyone has a solution?
Best regards,

Custom Resource

Hi all, i encounters errors with Custom::ServiceInstanceSchedule, i spent hours and yet still unable to resolve the error. I have attached the json file, appreciate your help! Thank you.
new 2.txt

Any performance issues with instances of about ~1500 across N different accounts

Can you let me know design consideration If we have 40 odd accounts and 1500 instances in all (EC2+RDS) running from a single account with cross account role assumption ?

  • Memory to be increased.
  • Time limit to be lambda max (5mins)
  • Any other ??
  • Will there parallel invocation of lambda for each account or single invocation does the job ?

Conversion of templates to YAML

Just wanted to ask whether you are open/willing to convert the templates to YAML?

We have started to use them and are exploring improvements for our own use cases that could also submitted upstream eventually, but we really do not enjoy working with JSON anymore, now that the more concise YAML format including support for comments is available, esp. for moderately complex stuff like the instance-scheduler.template.

Accordingly, we usually convert every imported template to YAML right away with your very own aws-cfn-template-flip, but that would make submitting pull requests here harder than necessary, so to gauge our options, I'd appreciate a hint whether you might consider that switch in the near future :)

Many thanks,
Steffen

Tags and Instances

Hi to everyone.

I tried to integrate the instance scheduler, according the AWS Implementation guide. I have these errors:

  1. Start and stop tags don't works;
  2. Some instances, for some reason I can't find, are correctly stopped but they don't come up and I have this message all day: (Desired state for instance from schedule "daily-stop" is running, last desired state was running, actual state is stopped)
  3. I can't find Cloud Metrics on CloudWatch.

BTW, thank you for your work!

Problem starting all instances in a schedule/period

Hello -- Thanks for this great tool. I have around 5 instances that use a single schedule but multiple periods. The periods differ only by the stop time not start time. All those periods are tied to that single schedule. It stops all the instances in the schedule however while starting it starts only 3 out of 5. These instances are not in ASG or anything special.
Spent a lot of time debugging - any help is appreciated.

Instance Tagging Syntax Documentaiton

In previous versions of the scheduler, there were tagging examples and syntax breakdown. That seems to be missing from this version's documentation.

Trying to schedule an Instance to Stop at 1AM and Start at 6AM.

Hi,

I am trying to implement Instance Scheduler to stop an Instance at 1 am and Start is back at 6 am. As far as I know the end time must be always greater than the start time in a period. So it didn't work when I directly specified those times in a period.
Then to accomplish this, I have created 2 periods, 1 period with endtime as 1 am and other period with begintime as 6 am. this didn't work either.
Can you help me with this task ?

Guide for migration from EC2 scheduler.

Hi,

This is awesome, just what I was looking for.
We have been using the EC2 scheduler for some time now and have been looking to expand it to schedule RDS stop/start times as well.
Do you have a guide/strategy/advice for migration from the EC2 scheduler?

Everyday period

What's the best way to define everyday in weekday option in the create-period command?

Will "mon-sun" work? Or you need to create two period, 1 for weekday and 1 for weekend?

Thanks in advanced!

Support for Aurora

Hello,

With the recent announcement of stop/start functionality for Aurora clusters, wanted to ask if there a plan for Instance Scheduler to support Aurora databases.

Kind Regards,
Maxim

Keeping RDS instances stopped for over 7 days

Hello,

I noticed that RDS instances that are scheduled to be stopped for periods longer than 7 days, are started automatically, irrespective of the schedule definition exactly 7 days after being stopped. This is likely due to the way RDS stop instance functionality is designed. I thought about 2 possible ways to override this and keep the instances stopped for over 7 days:

  1. Set enforced=true (which should stop the instances after the RDS service starts them automatically).
  2. Set use_maintenance_window=true (which should start the instances once per week for maintenance, and effectively reset the 7-day timer).

Do you have a recommendation about which of the 2 methods to use? Or perhaps, is there a better way to keep RDS instances stopped for periods longer than 7 days?

Regards,
Maxim

Instances not being stopped correctly

I'm seeing some pretty odd behaviour with my EC2 scheduler. My first thought is that it's because I'm trying to schedule OpsWorks EC2 instances, as the RDS schedule is working fine.

Below are logs showing the desired state is stopped, and that the Scheduler is not stopping the instances.

2018-02-18 - 06:00:23.248 - DEBUG : No running periods at this time found in schedule "instance-schedule-opsworks" for this time, desired state is stopped 2018-02-18 - 06:00:23.248 - DEBUG : Desired state for instance from schedule "instance-schedule-opsworks" is stopped, last desired state was stopped, actual state is running 2018-02-18 - 06:00:23.248 - INFO : Scheduler result {'752691938387': {'started': {}, 'resized': {}, 'stopped': {}}}

Search lamba function in wrong region

Search lamba function in wrong region (eu-central-1 instead ca-cental-1)

/usr/local/bin/scheduler-cli describe-schedules --region ca-central-1 --stack Scheduler

An error occurred (ResourceNotFoundException) when calling the Invoke operation:
Function not found: arn:aws:lambda:eu-central-1:450193214715:function:Scheduler-InstanceSchedulerMain

Lambda functions:
ca-canada-1 : Scheduler-InstanceSchedulerMain
ARN - arn:aws:lambda:ca-central-1:450193214715:function:Scheduler-InstanceSchedulerMain

CloudFormation:
Stack name: Scheduler
Stack ID: arn:aws:cloudformation:ca-central-1:450193214715:stack/Scheduler/3f95eda0-1264-11e8-a312-504dce1555fe
Status: CREATE_COMPLETE
Parameters:
Regions ca-central-1
DefaultTimezone Canada/Central
TagName Schedule

Scheduler-cli --region parameter not accepted

when I run scheduler-cli I get "You must specify a region" even when I gave the command one:

>scheduler-cli describe-schedules --region eu-central-1 --stack LZ-OPS-InstanceScheduler-Stack-1X8JI33HRJ78Q
You must specify a region.

Resize and StartStop Schedule

HI,

I am trying to schedule and instance to run from 6am to 10pm daily as office hour. But on weekday, it use t2.large instance and weekend use t2.micro.

i set the following

"periods": {
"SS": [
"[email protected]",
"[email protected]"
]

Where office-hours and weekend-office-hours is 05:59 - 21.59.

But the Instance start at midnight.
Can you please help out?
Thank You

Resize happens in the second cycle after the instance gets stopped in the first lambda cycle

The resizing of the ec2 instance happens in 2 stages In the first lambda run the ec2 instance gets stopped on trigger. In the second lambda run the resize happens. For the duration between first and second run the ec2 instance is in stopped state.
Details as follows:
Schedule:
Resize |   |   | { "[email protected]", "[email protected]", "[email protected]" } | Australia/Sydney
Period:
Aus-nonoff-hours |   | { "mon-fri" } |   |   | 19:00 | 23:59
Aus-nonoff-hours2 |   | { "mon-fri" } |   |   | 00:00 | 09:00
Aus-office-hours |   | { "mon-fri" } |   |   | 08:00 | 19:00

No profile support

The scheduler-cli does not support non-default profiles with the --profile option.

Input: scheduler-cli create-period --profile example --name weekdays --stack InstanceScheduler --weekdays mon-fri --begintime 6:00 --endtime 18:00

Output:
usage: scheduler-cli [-h] [--version]

                 {describe-periods,create-period,update-schedule,update-period,describe-schedule-usage,describe-schedules,delete-schedule,create-schedule,delete-period}
                 ...

scheduler-cli: error: unrecognized arguments: --profile example

I specify a start time only, but the running period is ~23:59.

I specify a start time only, but the running period is ~23:59.
(I am not fixed the issue yet -#19)


Implementation Guide said:

--endtime
The time when the running period stops. If begintime and endtime are not specified,
the running period is 00:00 – 23:59.
...

If you specify a start time only, the instance must be stopped manually. Similarly,
if you specify a stop time only, the instance must be started manually. If you don’t specify
either time, the solution uses the days of the week, days of the month, or months rules to start
and stop instances.

https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/instance-scheduler.pdf

and would it be helpful to add a "override_status=running" field in this situation?

Instance scheduler does not work as a nested CloudFormation template

Hi,

I launched instance scheduler as a nested template and the CloudWatch events handler does not run.
Failing event:

2018-07-19 - 06:30:33.847 - DEBUG : Request was not handled, no handler was able to handle this type of request
{
    "account": "xxxxxxxxxxxx",
    "region": "eu-west-1",
    "detail": {},
    "detail-type": "Scheduled Event",
    "source": "aws.events",
    "version": "0",
    "time": "2018-07-19T06:30:00Z",
    "id": "1af4d438-dfaf-400b-4acb-423c339cb0cf",
    "resources": [
        "arn:aws:events:eu-west-1:xxxxxxxxxxxx:rule/Instance-Scheduler-Scheduler-19BIN6Q-SchedulerRule-14DFUXIRT279M"
    ]
}

After debugging, it seems that the handler expects the event arn to begin with arn:aws:events:eu-west-1:xxxxxxxxxxxx:rule/Instance-Scheduler-Scheduler-19BIN6QDFUVTN-SchedulerRule.

It seems that the rule name was truncated and the handler does not run

Errors: Request was not handled, no handler was able to handle this type of request

Ive enabled the trace and get the above message for every event and scheduler doesnt work.
{
"account": "xxxxxx",
"region": "xxxx",
"detail": {},
"detail-type": "Scheduled Event",
"source": "aws.events",
"version": "0",
"time": "2018-10-17T02:15:00Z",
"id": "xxx",
"resources": [
"arn:aws:events:region:1234:rule/EC2-SchedulerRule"
]
}

Mind you. .. I have changed the cfn logical id's by appending with ec2 and rds to respective resources logical id as Im tryin to depoy two makeshift with schedulers for ec2 and rds separately.
so I dont see them working now for some reason.

Potential integration with AWS Systems Manager?

Hey there,

I really like this solution.

I have a question re: AWS Systems Manager Maintenance Windows. At my current company, we use SSM to take care of Operating System Patching, and we'd like servers to be on for the duration of the SSM Maintenance Windows without us having to make sure the instance scheduler windows include the SSM Maintenance Windows intervals. Are there any plans to make this solution aware of SSM Maintenance Windows?

Schedule with two periods isnt shutting down instances

I've got two periods one to stop at 02:00 and another to start at 08:00, i the tags on the instances are being fetched, but in the state table every instance has a state of "any".

I'm unable to apply these timings on one schedule due to BeginTime being earlier than EndTime. Not sure if there is a bug here or i'm doing something wrong?

This is my schedule and two periods:
"type (S)","name (S)","description (S)","weekdays (SS)","begintime (S)","endtime (S)","periods (SS)","timezone (S)"
"schedule","office-hours","Office hours ",,,,"{ ""office-hours-start"", ""office-hours-stop"" } ","US/Eastern"
"period","office-hours-start","Office hours start","{ ""mon-fri"" } ","08:00",,,
"period","office-hours-stop","Office hours stop","{ ""mon-fri"" } ",,"02:00",,

"started_tags" and "stopped_tags" not being set on scheduled actions

I've just setup the AWS Instance Scheduler and configured a single instance with a "Schedule" Tag to test it out. The schedule seems to be working fine; the instance is being Stopped and Started according to the schedule defined in DynamoDB.

However, the "Automated Tagging" feature doesn't seem to be working. The DynamoDB config looks correct; I simply copied and pasted the tag format from the documentation, and it appears in the "config" table as below:

"started_tags": {
    "S": "ScheduleMessage=Started on {year}/{month}/{day} at {hour}:{minute} {timezone}"
  },
"stopped_tags": {
    "S": "ScheduleMessage=Stopped on {year}/{month}/{day} at {hour}:{minute} {timezone}"
  }

There are no exceptions logged in the CloudWatch Log output for the tagging process, but they are simply not appearing against the instance. I was expecting to see a tag with the key name of "ScheduleMessage" and a value of "Started on 2018......".

Documentation

Documentation seems to be severely lacking given the number of options this thing has.

I far prefer the old version as I can get it up and running in 5 minutes.

issue with override_status

I'm attempting to Stop the instances but would like the ability to manually start the instances and not start them automatically. I've used the override_status to help with this and set it as Stopped. Currently i see mt state table showing all stopped , but that isn't the actual status of my instances. How can i achieve this?

Periods:
period1= Tue-Sat, start 0:00, stop 2:00
period2= Mon-Fri, start 08:00, stop 23:59

Schedule:
{
"description": {
"S": "Office hours"
},
"name": {
"S": "office-hours"
},
"override_status": {
"S": "stopped"
},
"periods": {
"SS": [
"period1",
"period2"
]
},
"timezone": {
"S": "US/Eastern"
},
"type": {
"S": "schedule"
}
}

Is gov-Cloud supported?

Hello,
Can we use AWS-instance-scheduler on AWS Gov-Cloud region? The script is showing ARN errors when deploying it.

Thanks

CloudWatch alarms thrown when UseCloudWatchMetrics is enabled

Hi,

I'm getting the following alarms when UseCloudWatchMetrics is enabled with the default settings. Are there any other things I should be changing from the default configuration so that these are not raised?

ConsumedReadCapacityUnits < 66 for 15 datapoints within 15 minutes
ConsumedReadCapacityUnits < 165 for 15 datapoints within 15 minutes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.