I cannot connect to my RDS instance when running the function, but can when running it locally. Here is my yaml
file which is in the same VPC as the instance. I ended up manually adding the AmazonRDSFullAccess policy and still no no avail.
service: wholesale-logging
provider:
name: aws
runtime: nodejs4.3
stage: dev
profile: lab
vpc:
securityGroupIds:
- sg-NNNNNNNN
- sg-NNNNNNNN
subnetIds:
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
- subnet-NNNNNNNN
iamRoleStatements:
- Effect: "Allow"
Action:
- "rds:*"
Resource: "*"
functions:
create:
handler: functions/logger/log.create
events:
- http:
path: log
method: post
and the function code:
'use strict';
const Massive = require('massive');
const db = Massive.connectSync({connectionString: 'postgres://delorean:back-to-the-future@wholesale-logging.cclyw00l55b3.us-east-1.rds.amazonaws.com:5432/logging'})
module.exports.create = (event, context, callback) => {
db.app.find({}, (err, apps) => {
console.log(apps)
const response = {
statusCode: 200,
body: {
data: 'test'
}
};
callback(null, response);
});
};