I have a postgresql db instance on AWS, I also have a lambda function.
I want to invoke this lambda function through a trigger function in my postgresql db.
I found this information: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL-Lambda.html#PostgreSQL-Lambda-errors
I have created a policy named "aws_lambda_rds_invoke_policy" with the permission
lambda:invokeFunction. Resource is '*' because I want this policy to work with all (future) lambda functions.I have created a role named "aws_lambda_rds_role" (Trusted entities: AWS Service: rds) with this policy attached.
I assume this role is automatically attached to my rds? (If not, how can I attach it?)
I have the following SQL-code:
SELECT * FROM aws_lambda.invoke(
aws_commons.create_lambda_function_arn('my-lambda-function-arn', 'eu-central-1'),
'{"hello":"world"}'::json
);
I get the following error:
ERROR: unable to access credentials stored with the database instance
HINT: Make sure that the desired Amazon Resource Name (ARN) is associated with the feature-name: "Lambda".
CONTEXT: SQL function "invoke" statement 1. 0.000 seconds. (Line 1).
When I delete the role I just created and run the SQL code again, it works?!
Don't get me wrong, I'm happy it works, but I'm wondering why, because I didn't "authorize" my db instance to run lambda functions.
Edit:
A few moments later, it stopped working. Could it be I just have to wait a few minutes before all changes (like adding a new role) are finished?