@@ -0,0 +1,3085 @@
+/**%0A * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A *%0A * This file is licensed under the Apache License, Version 2.0 (the %22License%22).%0A * You may not use this file except in compliance with the License. A copy of%0A * the License is located at%0A *%0A * http://aws.amazon.com/apache2.0/%0A *%0A * This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR%0A * CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A *%0A */%0A%0A// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BLambdaInvoke.java demonstrates how to invoke an AWS Lambda function by using the AWSLambda object%5D%0A// snippet-service:%5BLambda%5D%0A// snippet-keyword:%5BJava%5D%0A// snippet-keyword:%5BAmazon Lambda%5D%0A// snippet-keyword:%5BCode Sample%5D%0A// snippet-sourcetype:%5Bfull-example%5D%0A// snippet-sourcedate:%5B2019-11-19%5D%0A// snippet-sourceauthor:%5BAWS-scmacdon%5D%0A%0A// snippet-start:%5Blambda.java1.LambdaInvoke.complete%5D%0Apackage com.example.lambda ;%0A%0A// snippet-start:%5Blambda.java1.invoke.import%5D%0Aimport com.amazonaws.auth.profile.ProfileCredentialsProvider;%0Aimport com.amazonaws.regions.Regions;%0Aimport com.amazonaws.services.lambda.AWSLambda;%0Aimport com.amazonaws.services.lambda.AWSLambdaClientBuilder;%0Aimport com.amazonaws.services.lambda.model.InvokeRequest;%0Aimport com.amazonaws.services.lambda.model.InvokeResult;%0Aimport java.nio.charset.StandardCharsets;%0A// snippet-end:%5Blambda.java1.invoke.import%5D%0A%0A%0Apublic class LambdaInvokeFunction %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A         /*%0A        Function names appear as arn:aws:lambda:us-west-2:335556330391:function:HelloFunction%0A        you can retrieve the value by looking at the function in the AWS Console%0A         */%0A        if (args.length %3C 1) %7B%0A            System.out.println(%22Please specify a function name%22);%0A            System.exit(1);%0A        %7D%0A%0A        // snippet-start:%5Blambda.java1.invoke.main%5D%0A        String functionName = args%5B0%5D;%0A%0A        InvokeRequest invokeRequest = new InvokeRequest()%0A                .withFunctionName(functionName)%0A                .withPayload(%22%7B%5Cn%22 +%0A                        %22 %5C%22Hello %5C%22: %5C%22Paris%5C%22,%5Cn%22 +%0A                        %22 %5C%22countryCode%5C%22: %5C%22FR%5C%22%5Cn%22 +%0A                        %22%7D%22);%0A        InvokeResult invokeResult = null;%0A%0A        try %7B%0A            AWSLambda awsLambda = AWSLambdaClientBuilder.standard()%0A                    .withCredentials(new ProfileCredentialsProvider())%0A                    .withRegion(Regions.US_WEST_2).build();%0A%0A            invokeResult = awsLambda.invoke(invokeRequest);%0A%0A            String ans = new String(invokeResult.getPayload().array(), StandardCharsets.UTF_8);%0A%0A            //write out the return value%0A            System.out.println(ans);%0A        %7D%0A        catch (Exception e) %7B%0A            System.out.println(e);%0A        %7D%0A%0A        System.out.println(invokeResult.getStatusCode());%0A        // snippet-end:%5Blambda.java1.invoke.main%5D%0A    %7D%0A%7D%0A// snippet-end:%5Blambda.java1.LambdaInvoke.complete%5D%0A

Create LambdaInvokeFunction.java