UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 7.51 kB
"use strict";var _a,_b;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBridgeSchedulerCreateScheduleTask=exports.EventBridgeSchedulerTarget=exports.ActionAfterCompletion=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},sfn=()=>{var tmp=require("../../../aws-stepfunctions");return sfn=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},task_utils_1=()=>{var tmp=require("../private/task-utils");return task_utils_1=()=>tmp,tmp},ActionAfterCompletion;(function(ActionAfterCompletion2){ActionAfterCompletion2.NONE="NONE",ActionAfterCompletion2.DELETE="DELETE"})(ActionAfterCompletion||(exports.ActionAfterCompletion=ActionAfterCompletion={}));class EventBridgeSchedulerTarget{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgeSchedulerTargetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgeSchedulerTarget),error}this.validateProps(props),this.arn=props.arn,this.role=props.role,this.input=props.input,this.retryPolicy=props.retryPolicy,this.deadLetterQueue=props.deadLetterQueue}renderTargetObject(){return{Arn:this.arn,RoleArn:this.role.roleArn,Input:this.input,RetryPolicy:this.retryPolicy?{MaximumEventAgeInSeconds:this.retryPolicy.maximumEventAge.toSeconds(),MaximumRetryAttempts:this.retryPolicy.maximumRetryAttempts}:void 0,DeadLetterConfig:this.deadLetterQueue?{Arn:this.deadLetterQueue.queueArn}:void 0}}validateProps(props){if(props.input!==void 0&&!core_1().Token.isUnresolved(props.input)&&props.input.length<1)throw new(core_1()).UnscopedValidationError("Input must be at least 1 character long.");if(props.retryPolicy){if(!Number.isInteger(props.retryPolicy.maximumRetryAttempts)||props.retryPolicy.maximumRetryAttempts<0||props.retryPolicy.maximumRetryAttempts>185)throw new(core_1()).UnscopedValidationError(`MaximumRetryAttempts must be an integer between 0 and 185, got ${props.retryPolicy.maximumRetryAttempts}`);if(props.retryPolicy.maximumEventAge.toMilliseconds()<core_1().Duration.seconds(60).toMilliseconds()||props.retryPolicy.maximumEventAge.toSeconds()>86400)throw new(core_1()).UnscopedValidationError("MaximumEventAgeInSeconds must be between 60 and 86400 seconds")}}}exports.EventBridgeSchedulerTarget=EventBridgeSchedulerTarget,_a=JSII_RTTI_SYMBOL_1,EventBridgeSchedulerTarget[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EventBridgeSchedulerTarget",version:"2.202.0"};class EventBridgeSchedulerCreateScheduleTask extends sfn().TaskStateBase{static jsonPath(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgeSchedulerCreateScheduleTaskJsonPathProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonPath),error}return new EventBridgeSchedulerCreateScheduleTask(scope,id,props)}static jsonata(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgeSchedulerCreateScheduleTaskJsonataProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonata),error}return new EventBridgeSchedulerCreateScheduleTask(scope,id,{...props,queryLanguage:sfn().QueryLanguage.JSONATA})}constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgeSchedulerCreateScheduleTaskProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgeSchedulerCreateScheduleTask),error}this.validateProps(props),props.kmsKey?.grantDecrypt(props.target.role),this.integrationPattern=props.integrationPattern??sfn().IntegrationPattern.REQUEST_RESPONSE,this.taskPolicies=[new(iam()).PolicyStatement({resources:[core_1().Stack.of(this).formatArn({service:"scheduler",resource:"schedule",resourceName:`${this.props.groupName??"default"}/${this.props.scheduleName}`})],actions:["scheduler:CreateSchedule"]}),new(iam()).PolicyStatement({resources:[props.target.role.roleArn],actions:["iam:PassRole"]})]}_renderTask(topLevelQueryLanguage){const queryLanguage=sfn()._getActualQueryLanguage(topLevelQueryLanguage,this.props.queryLanguage);return{Resource:(0,task_utils_1().integrationResourceArn)("aws-sdk:scheduler","createSchedule",this.integrationPattern),...this._renderParametersOrArguments({ActionAfterCompletion:this.props.actionAfterCompletion??ActionAfterCompletion.NONE,ClientToken:this.props.clientToken,Description:this.props.description,EndDate:this.props.endDate?this.props.endDate.toISOString():void 0,FlexibleTimeWindow:{Mode:this.props.flexibleTimeWindow?"FLEXIBLE":"OFF",MaximumWindowInMinutes:this.props.flexibleTimeWindow?.toMinutes()},GroupName:this.props.groupName,KmsKeyArn:this.props.kmsKey?.keyArn,Name:this.props.scheduleName,ScheduleExpression:this.props.schedule.expressionString,ScheduleExpressionTimezone:this.props.timezone,StartDate:this.props.startDate?this.props.startDate.toISOString():void 0,State:this.props.enabled??!0?"ENABLED":"DISABLED",Target:this.props.target.renderTargetObject()},queryLanguage)}}validateProps(props){if(props.startDate&&props.endDate&&props.startDate>=props.endDate)throw new(core_1()).ValidationError("'startDate' must be before 'endDate'",this);if(props.clientToken!==void 0&&!core_1().Token.isUnresolved(props.clientToken)){if(props.clientToken.length>64||props.clientToken.length<1)throw new(core_1()).ValidationError(`ClientToken must be between 1 and 64 characters long. Got: ${props.clientToken.length}`,this);if(!/^[a-zA-Z0-9-_]+$/.test(props.clientToken))throw new(core_1()).ValidationError(`ClientToken must consist of alphanumeric characters, dashes, and underscores only, Got: ${props.clientToken}`,this)}if(props.description!==void 0&&!core_1().Token.isUnresolved(props.description)&&props.description.length>512)throw new(core_1()).ValidationError(`Description must be less than 512 characters long. Got: ${props.description.length}`,this);if(props.flexibleTimeWindow&&(props.flexibleTimeWindow.toMilliseconds()<core_1().Duration.minutes(1).toMilliseconds()||props.flexibleTimeWindow.toMinutes()>1440))throw new(core_1()).ValidationError("FlexibleTimeWindow must be between 1 and 1440 minutes",this);if(props.groupName!==void 0&&!core_1().Token.isUnresolved(props.groupName)){if(props.groupName.length<1||props.groupName.length>64)throw new(core_1()).ValidationError(`GroupName must be between 1 and 64 characters long. Got: ${props.groupName.length}`,this);if(!/^[a-zA-Z0-9-_.]+$/.test(props.groupName))throw new(core_1()).ValidationError(`GroupName must consist of alphanumeric characters, dashes, underscores, and periods only, Got: ${props.groupName}`,this)}if(props.timezone!==void 0&&!core_1().Token.isUnresolved(props.timezone)&&(props.timezone.length<1||props.timezone.length>50))throw new(core_1()).ValidationError(`Timezone must be between 1 and 50 characters long. Got: ${props.timezone.length}`,this)}}exports.EventBridgeSchedulerCreateScheduleTask=EventBridgeSchedulerCreateScheduleTask,_b=JSII_RTTI_SYMBOL_1,EventBridgeSchedulerCreateScheduleTask[_b]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EventBridgeSchedulerCreateScheduleTask",version:"2.202.0"};