Has anyone ever used Saloon to invoke an AWS Lambda function url? #247
Replies: 2 comments 3 replies
-
I got it working by "cloning" the headers from the signed Guzzle request using the AWS SDK. Not the cleanest solution, but it's working. Here's my protected function defaultHeaders(): array
{
$headers = ['Content-Type' => 'application/json'];
$request = new \GuzzleHttp\Psr7\Request('POST', config('aws.lambda_function_url'), $headers, $this->payload);
$credentials = new \Aws\Credentials\Credentials(config('aws.lambda_access_key_id'), config('aws.lambda_secret_access_key'));
$s4 = new \Aws\Signature\SignatureV4('lambda', config('aws.default_region'));
$signedRequest = $s4->signRequest($request, $credentials);
return $signedRequest->getHeaders();
} |
Beta Was this translation helpful? Give feedback.
-
I think with v3 we can now create a middlware and then use the boot() method to apply it in the connector. Here is a middleware I created for this as an example: https://gist.github.com/ejntaylor/83230fa3a0f68ac8806c562590add146 Not 100% sure on my middleware as signRequest() method as the expected parameter is '\Psr\Http\Message\RequestInterface' but '\Saloon\Http\Request' provided Will aim to update here once I get working fully. |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
has anyone ever used the awesome Saloon package to invoke an AWS Lambda function url?
AWS requires all requests to be signed with their AWS signing protocol (Signature Version 4). I've currently implemented this using the AWS SDK for PHP.
Going forward I would like to leverage Saloon to do the same and I was wondering if anyone has every got that working? I guess the challenge would be to somehow sign the Saloon request but I can't really find a starting point.
This is my current solution without Saloon:
Would be great if anyone would have an example for a Saloon implementation or point me in the right direction...
Beta Was this translation helpful? Give feedback.
All reactions