alpakka icon indicating copy to clipboard operation
alpakka copied to clipboard

aws LambdaAsyncClient with akka http client does not return function details when function ARN is used as a functionname parameter

Open ramazanyich opened this issue 3 years ago • 1 comments

Describe the bug

In our application we are using LambdaAsyncClient to get function details based on function ARN (eg. "arn:aws:lambda:eu-central-1:886760376729:function:testFunction"). Here is the API which we use:

  val httpclient = AkkaHttpClient.builder().withActorSystem(actorSystem).build()
  implicit val lambdaClient: LambdaAsyncClient = LambdaAsyncClient
    .builder()
    .credentialsProvider(credentialsProvider)
    .httpClient(httpclient)
    .build()
 val functionRequest =
      GetFunctionRequest.builder().functionName(name).build()
    lambdaClient
      .getFunction(functionRequest)

according to API we can use short functionname or full function ARN. If I provide a shortname of function, eg testFunction then I get correct response. But If I provide an ARN in functionRequest: "arn:aws:lambda:eu-central-1:886760376729:function:testFunction") then I get a LambdaException:

software.amazon.awssdk.services.lambda.model.LambdaException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: Lambda, Status Code: 403, Request ID: 3d1d1966-f2df-4e10-83e3-4a9564502f54)

I can perfectly get function details using AWS cli with same credentials by function ARN. Following executon works without exception:

aws lambda get-function --function-name arn:aws:lambda:eu-central-1:886760376729:function:testFunction

Expected behavior

the getFunction code should work if function ARN is used as functionName parameter

Current behavior

LAmbdaException is thrown:

software.amazon.awssdk.services.lambda.model.LambdaException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: Lambda, Status Code: 403, Request ID: 3d1d1966-f2df-4e10-83e3-4a9564502f54)

Steps to Reproduce

following code can be used (replace name,accessKey,secretKey by appropriate values):

val name="arn:aws:lambda:eu-central-1:886760376729:function:testFunction"
val accessKey="MY_ACCESS_KEY"
val secretKey="MY_SECRET_KEY"
val credentialsProvider: AwsCredentialsProvider = StaticCredentialsProvider.create(
    AwsBasicCredentials.create(
      accessKey,
      secretKey
    )
  )
 val httpclient = AkkaHttpClient.builder().withActorSystem(actorSystem).build()
  implicit val lambdaClient: LambdaAsyncClient = LambdaAsyncClient
    .builder()
    .credentialsProvider(credentialsProvider)
    .httpClient(httpclient)
    .build()
 val functionRequest =
      GetFunctionRequest.builder().functionName(name).build()
    lambdaClient
      .getFunction(functionRequest)

Possible Solution

No response

Context

_No response

Alpakka version used

2.0.2 NOTE: we cannot use alpakka 3.0.3 as we are using Play framework 2.8.8 and it depends on akka version 2.6.14...

JDK version used

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08) OpenJDK 64-Bit Server VM GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08, mixed mode, sharing)

Operating System and version

Ubuntu 20.04 LTS x86_84

ramazanyich avatar Oct 18 '21 22:10 ramazanyich

if I use NettyNioAsyncHttpClient.builder.build() as an HttpClient then using function ARN works. So something is wrong in the AkkaHttpClient implementation then...

ramazanyich avatar Oct 18 '21 22:10 ramazanyich