The Instance Scheduler monitors tags on instances. The default value for this parameter is Schedule. When you use a CloudFormation stack with the Instance Scheduler, you must define the Instance Scheduler TagName parameter. Choose the JSON view, and then use the following JSON template:.Choose Tables, and then choose the configuration table.Run the following command: $ scheduler-cli create-schedule -stack your_stack_name -name m-f9-5-sat9-12 -region eu-west-1 -periods mon-fri-9-5,sat-9-12 -timezone UTC To create a schedule, you can use the Instance Scheduler CLI, DynamoDB console, or Custom resources. Make sure to edit the templates for your requirements. Use a similar JSON template for the second period. Note: The preceding JSON template creates the first period. Choose the JSON view, and then use the following JavaScript object notation (JSON) template:.The configuration table allows you to specify the periods and schedules for your requirements. The state table stores the state of instances that the template stops and starts. Note: The Instance Scheduler template automatically creates two DynamoDB tables: state and configuration. Note: Replace your_stack_name with the stack name that you chose in step 4 and eu-west-1 with your own Region. $ scheduler-cli create-period -stack your_stack_name -region eu-west-1 -name sat-9-12 -begintime 9:00 -endtime 11:59 -weekdays sat For your own scenario, create the appropriate number of periods.Ĭonnect to the Instance Scheduler CLI, and then run the following commands: $ scheduler-cli create-period -stack your_stack_name -region eu-west-1 -name mon-fri-9-5 -begintime 9:00 -endtime 16:59 -weekdays mon-fri Start at 9 AM and stop at 12 PM on Saturdayįor this example, you must create two periods.Start at 9 AM and stop at 5 PM on Monday through Friday.The following example shows you how to create instances that: For more information on time periods, see Start and stop times. To create periods, you can use the Instance Scheduler CLI, DynamoDB console, or Custom resources. Review your settings, and then select I acknowledge that AWS CloudFormation might create IAM resources.For all other parameters, customize the stack for your needs.If you aren't using cross-account scheduling, then leave the parameter empty. Put in the ARNs for every role from the secondary accounts, separated by commas. For cross-account scheduling, provide the Cross-account roles parameter.(Optional) For Stopped tags, enter state=stopped.(Optional) For Started tags, enter state=started.For Enable CloudWatch Logs, choose Yes.For Enable CloudWatch Metrics, choose Yes.If the frequency isn't often enough for your needs, then you can adjust the Frequency property later. If you have a large number of instances, then use the highest frequency possible to avoid throttling. Note: The frequency is the number of minutes that pass before EventBridge initiates the Lambda function again for the Instance Scheduler. For Frequency, choose a frequency in minutes to run your scheduler.For Instance Scheduler TagName, you can keep the default value as Schedule, or customize it.In the navigation bar, select the AWS Region where you want to launch your stack with the template, and then choose Next.Note: The template is launched in the US East (N. Launch the instance scheduler stack page, and choose Launch Solution. Open CloudFormation with the Instance Scheduler template. The stack deploys an AWS Lambda function, an Amazon DynamoDB table, an Amazon EventBridge rule, and Amazon CloudWatch custom metrics. To verify that the installation is successful, run the following command: $ scheduler-cli -version Create a CloudFormation stack with the Instance Scheduler template If you haven't already done so, follow the instructions to install the Instance Scheduler command line interface (CLI). Resolution Install the Instance Scheduler You must add the key policy to the AWS Key Management Service (AWS KMS) key to allow the key user role to use this key. To start your instances, you must grant the Instance Scheduler a key user role with a key policy to encrypt or decrypt EBS volumes. Important: If you use the Instance Scheduler for EC2 instances with an encrypted Amazon Elastic Block Store (Amazon EBS), then your instances can't be started. Use CloudFormation templates to automate the deployment of the AWS Instance Scheduler.
0 Comments
Leave a Reply. |