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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ