Reputation: 42500
I am using serverless
framework to provision infrastructure on AWS. And I need to add database proxy
on my lambda but I couldn't find how to configure that. I have read the doc https://www.serverless.com/framework/docs/providers/aws/guide/functions/ but it doesn't mention anything relate to database proxy.
Below screenshot is the bottom of lambda in aws console. How can I add the proxy via serverless.yml
?
Upvotes: 5
Views: 1540
Reputation: 446
provider:
name: aws
iam:
role:
statements:
- Effect: "Allow"
Action:
- "rds-db:connect"
Resource: "arn:aws:rds-db:us-east-1:123123123:admin:blah-123abc123abc/*"
Note that "rds" in the ARN was changed to "rds-db" and "db-proxy" in the ARN was changed to "admin" (the admin user of the database). sls deploy
and check the lambda. You should see the proxy in the database proxy configuration section.
For example, the Proxy ARN I copied from RDS was
arn:aws:rds:us-east-1:123123123:db-proxy:blah-123abc123abc
and I edited it to be
arn:aws:rds-db:us-east-1:123123123:admin:blah-123abc123abc/*
Also, be sure your lambda is in the same Vpc as the RDS proxy or it will not be able to connect.
I am using:
% sls --version
Framework Core: 2.50.0
Plugin: 5.4.3
SDK: 4.2.3
Components: 3.13.2
Upvotes: 2