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

已提问 3 年前1702 查看次数
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

已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则