@ Action ( name = "Invoke AWS Lambda Function" , outputs = { @ Output ( Outputs . RETURN_CODE ) , @ Output ( Outputs . RETURN_RESULT ) , @ Output ( Outputs . EXCEPTION ) } , responses = { @ Response ( text = Outputs . SUCCESS , field = Outputs . RETURN_CODE , value = Outputs . SUCCESS_RETURN_CODE , matchType = MatchType . COMPARE_EQUAL , responseType = ResponseType . RESOLVED ) , @ Response ( text = Outputs . FAILURE , field = Outputs . RETURN_CODE , value = Outputs . FAILURE_RETURN_CODE , matchType = MatchType . COMPARE_EQUAL , responseType = ResponseType . ERROR ) } ) public Map < String , String > execute ( @ Param ( value = IDENTITY , required = true ) String identity , @ Param ( value = CREDENTIAL , required = true , encrypted = true ) String credential , @ Param ( value = REGION , required = true ) String region , @ Param ( value = PROXY_HOST ) String proxyHost , @ Param ( value = PROXY_PORT ) String proxyPort , @ Param ( value = PROXY_USERNAME ) String proxyUsername , @ Param ( value = PROXY_PASSWORD ) String proxyPassword , @ Param ( value = FUNCTION_NAME , required = true ) String function , @ Param ( value = FUNCTION_QUALIFIER ) String qualifier , @ Param ( value = FUNCTION_PAYLOAD ) String payload , @ Param ( value = CONNECT_TIMEOUT ) String connectTimeoutMs , @ Param ( value = EXECUTION_TIMEOUT ) String execTimeoutMs ) { proxyPort = defaultIfEmpty ( proxyPort , DefaultValues . PROXY_PORT ) ; connectTimeoutMs = defaultIfEmpty ( connectTimeoutMs , DefaultValues . CONNECT_TIMEOUT ) ; execTimeoutMs = defaultIfBlank ( execTimeoutMs , DefaultValues . EXEC_TIMEOUT ) ; qualifier = defaultIfBlank ( qualifier , DefaultValues . DEFAULT_FUNCTION_QUALIFIER ) ; ClientConfiguration lambdaClientConf = AmazonWebServiceClientUtil . getClientConfiguration ( proxyHost , proxyPort , proxyUsername , proxyPassword , connectTimeoutMs , execTimeoutMs ) ; AWSLambdaAsyncClient client = ( AWSLambdaAsyncClient ) AWSLambdaAsyncClientBuilder . standard ( ) . withClientConfiguration ( lambdaClientConf ) . withCredentials ( new AWSStaticCredentialsProvider ( new BasicAWSCredentials ( identity , credential ) ) ) . withRegion ( region ) . build ( ) ; InvokeRequest invokeRequest = new InvokeRequest ( ) . withFunctionName ( function ) . withQualifier ( qualifier ) . withPayload ( payload ) . withSdkClientExecutionTimeout ( Integer . parseInt ( execTimeoutMs ) ) ; try { InvokeResult invokeResult = client . invoke ( invokeRequest ) ; return OutputUtilities . getSuccessResultsMap ( new String ( invokeResult . getPayload ( ) . array ( ) ) ) ; } catch ( Exception e ) { return OutputUtilities . getFailureResultsMap ( e ) ; } }
Invokes an AWS Lambda Function in sync mode using AWS Java SDK