UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.67 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ScheduledAction=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),autoscaling_generated_1=require("./autoscaling.generated");class ScheduledAction extends core_1.Resource{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings.aws_cdk_lib_aws_autoscaling_ScheduledActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ScheduledAction),error}if(props.minCapacity===void 0&&props.maxCapacity===void 0&&props.desiredCapacity===void 0)throw new Error("At least one of minCapacity, maxCapacity, or desiredCapacity is required");props.schedule._bind(this);const resource=new autoscaling_generated_1.CfnScheduledAction(this,"Resource",{autoScalingGroupName:props.autoScalingGroup.autoScalingGroupName,startTime:formatISO(props.startTime),endTime:formatISO(props.endTime),minSize:props.minCapacity,maxSize:props.maxCapacity,desiredCapacity:props.desiredCapacity,recurrence:props.schedule.expressionString,timeZone:props.timeZone});this.scheduledActionName=resource.attrScheduledActionName}}exports.ScheduledAction=ScheduledAction,_a=JSII_RTTI_SYMBOL_1,ScheduledAction[_a]={fqn:"aws-cdk-lib.aws_autoscaling.ScheduledAction",version:"2.70.0"};function formatISO(date){if(!date)return;return date.getUTCFullYear()+"-"+pad(date.getUTCMonth()+1)+"-"+pad(date.getUTCDate())+"T"+pad(date.getUTCHours())+":"+pad(date.getUTCMinutes())+":"+pad(date.getUTCSeconds())+"Z";function pad(num){return num<10?"0"+num:num}}