"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CallAwsServiceCrossRegion=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},cross_region_aws_sdk_provider_generated_1=()=>{var tmp=require("../../../custom-resource-handlers/dist/aws-stepfunctions-tasks/cross-region-aws-sdk-provider.generated");return cross_region_aws_sdk_provider_generated_1=()=>tmp,tmp};class CallAwsServiceCrossRegion extends sfn().TaskStateBase{constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_CallAwsServiceCrossRegionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,CallAwsServiceCrossRegion),error}if(props.integrationPattern===sfn().IntegrationPattern.RUN_JOB)throw new Error("The RUN_JOB integration pattern is not supported for CallAwsService");if(!core_1().Token.isUnresolved(props.action)&&!props.action.startsWith(props.action[0]?.toLowerCase()))throw new Error(`action must be camelCase, got: ${props.action}`);const iamService={sfn:"states","cloudwatch-logs":"logs",mwaa:"airflow"}[props.service]??props.service;this.lambdaFunction=new(cross_region_aws_sdk_provider_generated_1()).CrossRegionAwsSdkSingletonFunction(this,"Handler",{uuid:"8a0c93f3-dbef-4b71-ac13-7aaf2048ce7e",lambdaPurpose:"CrossRegionAwsSdk",timeout:core_1().Duration.seconds(30)}),[new(iam()).PolicyStatement({resources:props.iamResources,actions:[props.iamAction??`${iamService}:${props.action}`]}),...props.additionalIamStatements??[]].forEach(policy=>this.lambdaFunction.addToRolePolicy(policy)),this.taskPolicies=[new(iam()).PolicyStatement({resources:this.lambdaFunction.resourceArnsForGrantInvoke,actions:["lambda:InvokeFunction"]})],(props.retryOnServiceExceptions??!0)&&this.addRetry({errors:["Lambda.ClientExecutionTimeoutException","Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],interval:core_1().Duration.seconds(2),maxAttempts:6,backoffRate:2})}_renderTask(){return{Resource:this.lambdaFunction.functionArn,Parameters:sfn().FieldUtils.renderObject({region:this.props.region,endpoint:this.props.endpoint,action:this.props.action,service:this.props.service,parameters:this.props.parameters})}}}exports.CallAwsServiceCrossRegion=CallAwsServiceCrossRegion,_a=JSII_RTTI_SYMBOL_1,CallAwsServiceCrossRegion[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.CallAwsServiceCrossRegion",version:"2.159.0"};
