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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠