Search code examples
phpamazon-web-servicesamazon-s3aws-php-sdk

S3 CreateEventSourceMapping triggers "Operation not found" error


I'm trying to create source maps so when someone uploads something inside the bucket, Lambda will trigger a previously created function, as described here

But, when I call this:

$fnName = 'my_function';
$s3->createEventSourceMapping([
    //'BatchSize' => <integer>,
    'Enabled' => true, //<boolean>
    'EventSourceArn' => 'arn:aws:s3:::'.S3_BUCKET.'/'.$fnName, // REQUIRED
    'FunctionName' => $fnName, // REQUIRED
    'StartingPosition' => 'LATEST', //'TRIM_HORIZON|LATEST|AT_TIMESTAMP',
    //'StartingPositionTimestamp' => <integer || string || DateTime>,
]);

I get the following error message Operation not found: CreateEventSourceMapping.

Some of those parameters are not active because according to the documentation found in https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-lambda-2015-03-31.html#createeventsourcemapping they have default values or aren't required (as far as I undestand)

At the moment I am using PHP SDK (ver 3.94.2). Is there something I am missing?


Solution

  • The createEventSourceMapping() method is a method on a Lambda client, not on an S3 client.