# Access RDS Database by Name like DynamoDB

**URL:** <https://forum.serverless.com/t/access-rds-database-by-name-like-dynamodb/3512>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [January 16, 2018, 12:08am UTC](https://forum.serverless.com/t/access-rds-database-by-name-like-dynamodb/3512 "2018-01-16T00:08:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![x11joe](https://avatars.discourse-cdn.com/v4/letter/x/50afbb/32.png) [@x11joe](https://forum.serverless.com/u/x11joe)\
**Post date:** [January 16, 2018, 12:08am UTC](https://forum.serverless.com/t/access-rds-database-by-name-like-dynamodb/3512/1 "2018-01-16T00:08:51Z")

</div>

My resources section looks like below in my serverless file.

```
resources:
  Resources:
    uploadBucket:
       Type: AWS::S3::Bucket
       Properties:
         BucketName: ${self:custom.uploadBucket}
    RDSDatabase:
      Type: AWS::RDS::DBInstance
      Properties:
        Engine : mysql
        DBInstanceIdentifier: ${self:custom.databaseName}
        MasterUsername: TestUser123
        MasterUserPassword: TestPass123
        DBInstanceClass : db.m1.small
        AllocatedStorage: '5'
        PubliclyAccessible: true
      DeletionPolicy: Snapshot

```

I created the DBInstanceIdentifier dynamically based on the stage when I run servleress deploy, like this, `serverless deploy --stage dev`

I am able to create DynamoDB Tables dynamically and connect to them merely referencing the tablename in my Lambda functions. RDS requires a hostname,username and password. **Is there a way to connect to RDS like how DynamoDB works by its database name?**

I posted a more detailed question here [https://stackoverflow.com/questions/48272249/can-you-connect-to-an-amazon-rds-instance-by-database-name-instead-of-hostname-i](https://stackoverflow.com/questions/48272249/can-you-connect-to-an-amazon-rds-instance-by-database-name-instead-of-hostname-i)

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [January 24, 2018, 2:24am UTC](https://forum.serverless.com/t/access-rds-database-by-name-like-dynamodb/3512/2 "2018-01-24T02:24:34Z")

</div>

AWS supports IAM authentication for MySQL and Aurora

[https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html)

The other option is to set some variables like `RDS_USERNAME` and `RDS_PASSWORD` in your `serverless.yml` then use the variables for `MasterUsername` and `MasterUserPassword` and pass them into your Lambda as environment variables.
