Aurora Postgres Invoke Lambda with aws_commons.create_lambda_function_arn

0

I'm running Aurora Postgres 12.4 and trying to invoke Lambda function from trigger function. The problem is that somehow invoking lambda function using aws_commons.create_lambda_function_arn composite structure function name doesn't work. But invoking works giving full arn. I'm sure I had this working first when testing the functionality but can't figure out what has changed since then.

Here are the relevant commands run from console towards Aurora Postgres database and respective output in comments. Note that the last commands shows the format, which is working. So apparently something wrong with aws_commons.create_lambda_function_arn maybe?

CREATE EXTENSION IF NOT EXISTS aws_lambda CASCADE;
/*
extension "aws_lambda" already exists, skipping
*/

SELECT aws_commons.create_lambda_function_arn(
'arn:aws:lambda:eu-west-1:xxxxx:function:<Lambda function name>'
) AS aws_lambda_arn
/*
OK -> 1 row retrieved starting from...
*/

-- Syncronous invocation using structure
SELECT * FROM aws_lambda.invoke('aws_lambda_arn', '{"body": "Hello from Postgres!"}'::json);
/*
ERROR: invoke API failed Detail: AWS Lambda client returned 'User: arn:aws:sts::xxxxxxx:assumed-role/<IAM role>/dbc-role-mem-id-636424 is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:eu-west-1:xxxxx:function:aws_lambda_arn'
*/

-- Asyncronous invocation using structure
SELECT * FROM aws_lambda.invoke('aws_lambda_arn', '{"body": "Hello from Postgres!"}'::json, 'Event');
/*
ERROR: invoke API failed Detail: AWS Lambda client returned 'curlCode: 6, Couldn't resolve host name'.
*/

-- Syncronous invocation using Lambda arn directly
SELECT * FROM aws_lambda.invoke('arn:aws:lambda:eu-west-1:xxxxx:function:<Lambda function name>', '{"body": "Hello from Postgres!"}'::json);
/*
This invocation works fine.
*/

demandé il y a 3 ans1702 vues
1 réponse
0

The reason was aws_lambda.invoke signature. There are two versions, pay close attention:
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL-Lambda.html#aws_lambda.invoke

répondu il y a 3 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions