5

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?

enter image description here

1
  • 1
    Probably need to custom define it using Resources section. Commented Oct 20, 2020 at 11:39

1 Answer 1

2
  1. Go to your RDS server and click on the proxy
  2. Copy the Proxy ARN
  3. Edit your serverless.yml and
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
Sign up to request clarification or add additional context in comments.

1 Comment

In my case I needed to change dbuser in resource string to admin like arn:aws:rds-db:us-east-1:123123123:dbuser:blah-123abc123abc/* as documented here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.