KingAndrew
KingAndrew

Reputation: 1165

How to add a Stored Procedure to AWS RDS Aurora-Serverless?

I have an Aurora Serverless MySql database that I would like to add stored procedures to. I tried the console query editor but that does not work. The message I receive is: You haven't finished running any queries yet.

I have hunted through a LOT of AWS docs but can not find how to do it.

Could someone please point me in the correct direction?

Andrew

Upvotes: 2

Views: 7212

Answers (2)

Tim Mironov
Tim Mironov

Reputation: 859

I would recommend using the CLoud9 environment in AWS, this way you can access the DB from environment's CLI, just like a regular SQL server.

Upvotes: 0

KingAndrew
KingAndrew

Reputation: 1165

I found an answer in an other question: https://stackoverflow.com/a/60309133/222837

I was hoping for an article or something from AWS but this gets the job done. You need to use the CLI and push up a file with the Stored Procedure in it.

cat function.sql | xargs -0 aws rds-data execute-statement \
    --resource-arn arn:aws:rds:eu-west-1:xxx:cluster:cluster-name \
    --secret-arn arn:aws:secretsmanager:eu-west-1:xxx:secret:secret-name-xxx \
    --database "database_name" \
    --sql

Upvotes: 2

Related Questions