Signing a request from Edge Function to reach a Lambda function using Typescript and Sdkv3

0

Hi All, I'm currently trying to implement an integration in an Edge function to call a Lambda Function through an FunctionUrl which has IAM as auth-type. I originally followed this blog post available in aws blogs: https://aws.amazon.com/blogs/compute/protecting-an-aws-lambda-function-url-with-amazon-cloudfront-and-lambdaedge/ Using Javascript it worked as expected, however I couldn't find any official references for typescript with sdk-v3 equivalent. I tried @aws-sdk/signature-v4 assuming both of my function and edge function as deployed in us-east-1, however for testing purpose I also tried the @aws-sdk/signature-v4-multi-region with cross-region deployment. To sign the request I tried: const req = new HttpRequest({ method: request.method, protocol: 'https', hostname:${host}, path: path, }); const credentialProvider = fromNodeProviderChain(); const credentials = await credentialProvider(); const v4 = new SignatureV4MultiRegion({ service: ${AWS_SERVICE}, region, credentials, sha256: Sha256, }); const signedRequest = await v4.sign(req); By calling the edge function through the Cloudfront mapped path it I receive the following error: {"message":"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."}

I'm currently not able to figure out ways of debugging it properly and discover which field doesn't match, so I'm not sure if I'm just missing any obvious config on service level or instance in the code. Any support diving into the steps to properly debug it are much appreciated.

Thank you in advance.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠