Thomas Lang
Thomas Lang

Reputation: 61

Connection from Lambda to Aurora database fails

I've set up an Aurora PostgreSQL compatible database. I can connect to the database via the public address but I'm not able to connect via a Lambda function which is placed in the same VPC.

This is just a test environment and the security settings are weak. In the network settings I tried to use "no VPC" and I tried my default VPC where the database and the lambda are placed. But this doesn't make a difference.

This is my nodejs code to create a simple Select statement:

var params = {
  awsSecretStoreArn: '{mySecurityARN}',
  dbClusterOrInstanceArn: 'myDB-ARN', 
  sqlStatements: 'SELECT * FROM userrole',
  database: 'test',
  schema: 'user'
};

const aurora = new AWS.RDSDataService();

let userrightData = await aurora.executeSql(params).promise();

When I start my test in the AWS GUI I get following errors:

  "errorType": "UnknownEndpoint",
  "errorMessage": "Inaccessible host: `rds-data.eu-central- 1.amazonaws.com'. This service may not be available in the `eu-central-1' region.",
  "trace": [
  "UnknownEndpoint: Inaccessible host: `rds-data.eu-central-1.amazonaws.com'. This service may not be available in the `eu-central-1' region.",

I've already checked the tutorial of Amazon but I can't find a point I did't try.

Upvotes: 2

Views: 510

Answers (1)

Thomas Lang
Thomas Lang

Reputation: 61

The error message "This service may not be available in the `eu-central-1' region." is absolutely right because in eu-central-1 an Aurora Serverless database is not available.

I configured an Aurora Postgres and not an Aurora Serverless DB.

"AWS.RDSDataService()", what I wanted to use to connect to the RDB, is only available in relation to an Aurora Serverless instance. It's described here: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDSDataService.html.

This is the reason why this error message appeared.

Upvotes: 1

Related Questions