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