I'm trying to trigger a lambda in account 'B' by a Kinesis stream in account 'A'. This is similar to what's described here, except the example uses S3 instead of Kinesis.
To do this, I'm trying to set up the right permissions, but running into difficulties.
First I add this permission:
aws lambda add-permission \
--function-name "$function_name" \
--statement-id 'Id-123' \
--action "lambda:InvokeFunction" \
--principal $source_account \
--source-arn "$stream_arn" \
--source-account $source_account \
--region us-east-1 \
--profile "$profile"
Where $source_account
is the account ID for 'A'.
Then I attempt to create the source mapping:
aws lambda create-event-source-mapping \
--event-source-arn "$stream_arn" \
--function-name "$function_name" \
--starting-position TRIM_HORIZON \
--region us-east-1 \
--profile "$profile"
And I get the following error:
A client error (InvalidParameterValueException) occurred when calling the CreateEventSourceMapping operation: Role and event source must be in the same account as the cloud function
I don't understand this error. Is it saying what I'm trying to do is impossible? But then how was it accomplished here with S3, which is essentially the same mechanism?