aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 1.73 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CallApiGatewayEndpointBase=void 0;const iam=require("../../../aws-iam"),sfn=require("../../../aws-stepfunctions"),base_types_1=require("./base-types"),task_utils_1=require("../private/task-utils");class CallApiGatewayEndpointBase extends sfn.TaskStateBase{constructor(scope,id,props){if(super(scope,id,props),this.baseProps=props,this.integrationPattern=props.integrationPattern??sfn.IntegrationPattern.REQUEST_RESPONSE,task_utils_1.validatePatternSupported(this.integrationPattern,CallApiGatewayEndpointBase.SUPPORTED_INTEGRATION_PATTERNS),this.integrationPattern===sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN&&!sfn.FieldUtils.containsTaskToken(this.baseProps.headers))throw new Error("Task Token is required in `headers` for WAIT_FOR_TASK_TOKEN pattern. Use JsonPath.taskToken to set the token.")}_renderTask(){return{Resource:task_utils_1.integrationResourceArn("apigateway","invoke",this.integrationPattern),Parameters:sfn.FieldUtils.renderObject({ApiEndpoint:this.apiEndpoint,Method:this.baseProps.method,Headers:this.baseProps.headers?.value,Stage:this.stageName,Path:this.baseProps.apiPath,QueryParameters:this.baseProps.queryParameters?.value,RequestBody:this.baseProps.requestBody?.value,AuthType:this.baseProps.authType?this.baseProps.authType:"NO_AUTH"})}}createPolicyStatements(){return this.baseProps.authType===base_types_1.AuthType.NO_AUTH?[]:[new iam.PolicyStatement({resources:[this.arnForExecuteApi],actions:["execute-api:Invoke"]})]}}exports.CallApiGatewayEndpointBase=CallApiGatewayEndpointBase,CallApiGatewayEndpointBase.SUPPORTED_INTEGRATION_PATTERNS=[sfn.IntegrationPattern.REQUEST_RESPONSE,sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN];