I am trying to invoke an existing aws-lambda function from my php code in laravel to get the data and save in my database. The actual command I want to invoke is the following:
aws lambda invoke --function-name expo2020-metrics --region eu-west-3 response.json
Here is the code I'm using to invoke my function:
use Aws\Lambda\LambdaClient;use Aws\Credentials\Credentials;
$credentials = new Credentials('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY');
$client = LambdaClient::factory(array(
'credentials' => $credentials,
'region' => 'eu-west-3',
'version' => 'latest'
));
$result = $client->getFunction(array(
'FunctionName' => 'expo2020-metrics',
));
But I'm getting the following response:
{"Message":"User: arn:aws:iam::677537359471:user/customer/expo2020-metrics is not authorized to perform: lambda: GetFunction on resource: arn:aws:lambda:eu-west-3:677537359471:function:expo2020-metrics"}
I'm not sure that I'm using the right code to invoke the function or not. I am using the PHP sdk provided by AWS.