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.
*/

已提問 4 年前檢視次數 1975 次
1 個回答
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

已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南