Open wildthing81 opened 5 years ago
Hi Ramaswamy.
From what you described, I guess that the DB_DIALECT parameter is missing. You have to set the DB_DIALECT value as one of the options presented below, according to the database you are working with: DB_DIALECT: 'mysql' OR 'mariadb' OR 'postgres' OR 'mssql'
If the issue persists, let me know so that I can help you.
I have added the DB_DIALECT as well. still the same problem. The issue here is how to resolve DB parameters when they are dynamically generated from an RDS resource section within the same serverless yml file & stored as properties in 'custom' section of the yml ?
Just encountered the same issue.
I have the following:
Resources:
RDS:
Type: "AWS::RDS::DBInstance"
...
Then, to get the endpoint and the port:
dbEndpoint:
"Fn::GetAtt":
- RDS
- Endpoint.Address
dbPort:
"Fn::GetAtt":
- RDS
- Endpoint.Port
On the environment:
environment:
STAGE: ${self:provider.stage}
DB_DIALECT: 'postgres'
DB_PROTOCOL: ${self:custom.dbProtocol}
DB_USERNAME: ${self:custom.dbUsername}
DB_PASSWORD: ${self:custom.dbPassword}
DB_HOST: ${self:custom.dbEndpoint}
DB_PORT: ${self:custom.dbPort}
DB_NAME: ${self:custom.dbName}
Then I get:
RangeError: "port" option should be >= 0 and < 65536: NaN
Alright. Now if I hardcode the port, that error disappears, but this comes up:
SequelizeHostNotFoundError: getaddrinfo ENOTFOUND [object Object] [object Object]:5432
I'm also getting this issue. I have an RDS resource declared:
...
resources:
Resources:
RDSInstance:
Type: AWS::RDS::DBInstance
Properties:
...
Then I set my environment variables like this:
custom:
databaseHost: !GetAtt RDSInstance.Endpoint.Address
...
provider:
environment:
DB_DIALECT: postgres
DB_HOST: ${self:custom.databaseHost}
...
But when I run sls migrations up
it always tries to connect to 127.0.0.1.
But the environment variable is set correctly, I can see in the Lambda console that the DB_HOST
has the correct value.
My serverless.yml contains DB parameters like so environment: DB_NAME: ${self:custom.database.name} DB_USERNAME: ${self:custom.database.username} DB_PASSWORD: ${self:custom.database.password} DB_HOST: ${self:custom.database.host} DB_PORT: ${self:custom.database.port}
Will these parameters get resolved if I run 'sls migrations up' . I am currently getting a
Serverless: Setting up connections... Serverless: Looking for pending migrations... Serverless: Error trying to apply migrations: SequelizeConnectionError: connect ENOENT [object Object]