Source:
private InvokeResult invokeLambda(String payload) { try { AWSCredentialsProvider credentialsProvider; if (StringUtils.isEmpty(accessKey) && StringUtils.isEmpty(secretKey)) { if (log.isDebugEnabled()) { log.debug("Using temporary credentials supplied by the IAM role attached to the EC2 instance"); } credentialsProvider = InstanceProfileCredentialsProvider.getInstance(); } else if (!StringUtils.isEmpty(accessKey) && !StringUtils.isEmpty(secretKey)) { if (log.isDebugEnabled()) { log.debug("Using user given stored credentials"); } if (secretKey.length() == APIConstants.AWS_ENCRYPTED_SECRET_KEY_LENGTH) { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); setSecretKey(new String(cryptoUtil.base64DecodeAndDecrypt(secretKey), APIConstants.DigestAuthConstants.CHARSET)); } BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); credentialsProvider = new AWSStaticCredentialsProvider(awsCredentials); } else { log.error("Missing AWS Credentials"); return null; } if (resourceTimeout < 1000 && resourceTimeout > 900000) { setResourceTimeout(APIConstants.AWS_DEFAULT_CONNECTION_TIMEOUT); } InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(resourceName) .withPayload(payload) .withInvocationType(InvocationType.RequestResponse) .withSdkClientExecutionTimeout(resourceTimeout); AWSLambda awsLambda = AWSLambdaClientBuilder.standard() .withCredentials(credentialsProvider) .build(); return awsLambda.invoke(invokeRequest); } catch (SdkClientException e) { log.error("Error while invoking the lambda function", e); } catch (CryptoException | UnsupportedEncodingException e) { log.error("Error while decrypting the secret key", e); } return null; }

Target:
private InvokeResult invokeLambda(String payload) { try { AWSCredentialsProvider credentialsProvider; if (StringUtils.isEmpty(accessKey) && StringUtils.isEmpty(secretKey)) { if (log.isDebugEnabled()) { log.debug("Using temporary credentials supplied by the IAM role attached to the EC2 instance"); } credentialsProvider = InstanceProfileCredentialsProvider.getInstance(); } else if (!StringUtils.isEmpty(accessKey) && !StringUtils.isEmpty(secretKey)) { if (log.isDebugEnabled()) { log.debug("Using user given stored credentials"); } if (secretKey.length() == APIConstants.AWS_ENCRYPTED_SECRET_KEY_LENGTH) { CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); setSecretKey(new String(cryptoUtil.base64DecodeAndDecrypt(secretKey), APIConstants.DigestAuthConstants.CHARSET)); } BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); credentialsProvider = new AWSStaticCredentialsProvider(awsCredentials); } else { log.error("Missing AWS Credentials"); return null; } if (resourceTimeout < 1000 || resourceTimeout > 900000) { setResourceTimeout(APIConstants.AWS_DEFAULT_CONNECTION_TIMEOUT); } InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(resourceName) .withPayload(payload) .withInvocationType(InvocationType.RequestResponse) .withSdkClientExecutionTimeout(resourceTimeout); AWSLambda awsLambda = AWSLambdaClientBuilder.standard() .withCredentials(credentialsProvider) .build(); return awsLambda.invoke(invokeRequest); } catch (SdkClientException e) { log.error("Error while invoking the lambda function", e); } catch (CryptoException | UnsupportedEncodingException e) { log.error("Error while decrypting the secret key", e); } return null; }