serverless-step-functions
serverless-step-functions copied to clipboard
Feature request: Allow customization of the APIGW integration template
Thanks @horike37 and team for this nice plugin, it's really helping with accelerating StepFunctions development!
I was wondering if it's possible to customize the Body Mapping templates defined for the APIGW Integration with StepFunctions service. Maybe using the existing Serverless way of template definition?
This would be useful in our Order processing use case to customize the execution name used in the StartExecution integration call and provide more context for each execution - e.g. for the application/json template -
- Current:
#set( $body = $util.escapeJavaScript($input.json('$')) )
{"input": "$body","name": "$context.requestId","stateMachineArn":"arn:aws:states:ap-northeast-1:11233455446:stateMachine:GreetingStateMachineDEV-Pl8hGTHgX8no"}
- Proposed:
#set( $body = $util.escapeJavaScript($input.json('$')) )
#set( $orderId = $input.json('$.OrderId') )
{"input": "$body","name": "$orderId","stateMachineArn":"arn:aws:states:ap-northeast-1:11233455446:stateMachine:GreetingStateMachineDEV-Pl8hGTHgX8no"}
which makes the execution easily searchable by custom OrderId like so -

I believe this is coded into the plugin at present and cannot be customized - https://github.com/horike37/serverless-step-functions/blob/19ab556f83f641804b7ee8de73d8a83dc449009a/lib/deploy/events/apiGateway/methods.js#L68-L95
Thanks again!
Thank you for the suggestion @elescrim :+1: The code you provided looks good :smile: Could you please send PR so that we will go ahead this implementation?
Is there a reason this can't be overridden in the serverless.yml definition? I'd like to be able to define custom mapping definitions in the request template.
@dbaghdanov There is no special reason for that. it isn't only implemented yet.