UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 2.44 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBridgePutEvents=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),iam=require("../../../aws-iam"),sfn=require("../../../aws-stepfunctions"),cdk=require("../../../core"),task_utils_1=require("../private/task-utils");class EventBridgePutEvents extends sfn.TaskStateBase{constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgePutEvents),error}if(this.integrationPattern=props.integrationPattern??sfn.IntegrationPattern.REQUEST_RESPONSE,task_utils_1.validatePatternSupported(this.integrationPattern,EventBridgePutEvents.SUPPORTED_INTEGRATION_PATTERNS),this.integrationPattern===sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN&&!sfn.FieldUtils.containsTaskToken(props.entries.map(entry=>entry.detail)))throw new Error("Task Token is required in `entries`. Use JsonPath.taskToken to set the token.");this.validateEntries(),this.taskPolicies=[new iam.PolicyStatement({actions:["events:PutEvents"],resources:this.eventBusArns})]}get eventBusArns(){return this.props.entries.map(entry=>entry.eventBus?entry.eventBus.eventBusArn:cdk.Stack.of(this).formatArn({resource:"event-bus",resourceName:"default",arnFormat:cdk.ArnFormat.SLASH_RESOURCE_NAME,service:"events"}))}_renderTask(){return{Resource:task_utils_1.integrationResourceArn("events","putEvents",this.integrationPattern),Parameters:sfn.FieldUtils.renderObject({Entries:this.renderEntries()})}}renderEntries(){return this.props.entries.map(entry=>{if(entry.source?.startsWith("aws"))throw new Error('Event source cannot start with "aws."');return{Detail:entry.detail?.value,DetailType:entry.detailType,EventBusName:entry.eventBus?.eventBusArn,Source:entry.source}})}validateEntries(){if(this.props.entries.length<=0)throw new Error("Value for property `entries` must be a non-empty array.")}}exports.EventBridgePutEvents=EventBridgePutEvents,_a=JSII_RTTI_SYMBOL_1,EventBridgePutEvents[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EventBridgePutEvents",version:"2.70.0"},EventBridgePutEvents.SUPPORTED_INTEGRATION_PATTERNS=[sfn.IntegrationPattern.REQUEST_RESPONSE,sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN];