Reputation: 31
I have a question while using AWS Lambda <-> AWS RDS.
Now I have a connection with one lambda function and one RDS db schema.
In the Lambda function, I have config.py with this json code.
dbinfo = {
'db' = ~
'user' = ~
'passwd'= ~
'schema' = ~
}
Lambda function works for connecting in to the RDS schema, and calling a stored procedure.
Right now, there is only one schema that I have to connect with Lambda function.
But soon that schema will be changed to a sharding structure. (ex. game1 schema -> game1 , game2 schemas)
That stored procedure will be stored in om both schemas (game1, game2).
How to connect two schemas in one Lambda function?
Upvotes: 1
Views: 235
Reputation: 2972
Structure your config.py
file something like:
dbinfo = {
'shard1' = {
'db' = ~
'user' = ~
'passwd'= ~
'schema' = ~
},
'shard2' = {
'db' = ~
'user' = ~
'passwd'= ~
'schema' = ~
},
}
and inside of your Lambda, create multiple RDS clients for each shard.
And FWIW, you might want to consider storing your password outside of code in AWS ParameterStore.
Upvotes: 0