1
votes

I'm trying to invoke AWS Lambda code via the AWS Java SDK, but it is producing a strange error that i've only found on google as a defect that was supposedly fixed a while ago.


The service name : "BackplaneExecutionService" identified from the payload does not agree with the service name : "AWSLambda" specified in the transport header (Service: AWSLambda; Status Code: 403; Error Code: AccessDeniedException; Request ID: c40b5e2e-807b-11e5-88d6-6f0496ed99c7)
com.amazonaws.AmazonServiceException: The service name : "BackplaneExecutionService" identified from the payload does not agree with the service name : "AWSLambda" specified in the transport header (Service: AWSLambda; Status Code: 403; Error Code: AccessDeniedException; Request ID: c40b5e2e-807b-11e5-88d6-6f0496ed99c7)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:710)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:385)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
    at com.amazonaws.services.lambda.AWSLambdaClient.invoke(AWSLambdaClient.java:387)
    at com.amazonaws.services.lambda.AWSLambdaClient.invoke(AWSLambdaClient.java:322)
    at .....

My code to invoke this looks like:

    BasicAWSCredentials androidClientCredentials = new BasicAWSCredentials(
            "cccccccc",
            "ccc+cc/cc"
    );
    AWSLambdaClient lambdaClient = new AWSLambdaClient(androidClientCredentials);
    lambdaClient.setRegion(Region.getRegion(Regions.US_EAST_1));
    lambdaClient.setEndpoint("https://cc.execute-api.us-east-1.amazonaws.com/prod/asdf");
    lambdaClient.setServiceNameIntern("execute-api");
    InvokeRequest request = new InvokeRequest();
    request.setInvocationType(InvocationType.RequestResponse);
    request.setFunctionName("arn:aws:lambda:us-east-1:1234:asdf:$LATEST");
    Map<String,String> payload = new HashMap<>(4);
    payload.put("username",U);
    payload.put("password", P);
    request.setPayload(ByteBuffer.wrap(new JSONObject(payload).toString().getBytes()));
    InvokeResult result = lambdaClient.invoke(request);

Any thoughts or direction?

1
Why are you calling setEndpoint and setServiceNameIntern? Typically you should not need to when invoking a Lambda. Also you would typically call setFunctionName("asdf") to invoke the latest version of that Lambda function - you can supply the ARN but typically you would not.jarmod

1 Answers

0
votes

Thanks @jarmod, This error was due to my confusion about how to make Lambda functions accessible. It seemed from the UI i needed to create an "API endpoint". After reading more about creating APIs via AWS it seems this is a special feature for the purpose of creating custom endpoint URLs (I do not fully understand the feature yet).

I learned you do not need a "API endpoint" and I was able to remove the setEndpoint and setServiceNameInter method calls