cancel
Showing results for 
Search instead for 
Did you mean: 

Error with user provided postgresql-service from AWS

former_member603667
Participant
0 Kudos

Hi Community,

because of the new BYOA-concept of SAP I tried to create a user-provided service instance of an AWS-postgresql-db-service to consume it from a node.js app. Unfortunately something goes wrong with the credentials or the uri. Has anyone a working example or knows, what wrong in my case? I followed this blog post: Blogpost

{
"username": "postgres",
"password": "*********",
"db": "postgres",
"hostname": "elb-postgresql.c8uizrkzmtox.eu-central-1.rds.amazonaws.com",
"port": "5432",
"uri": "jdbc:postgresql://elb-postgresql.c8uizrkzmtox.eu-central-1.rds.amazonaws.com:5432/postgres?user=postgres&password=*********"
}

To get the URI in my node.js app I'm doing the following: Is this still right, or do I have to adapt it?

function returnUriToDB() {
	var uri = '';
	if (process.env.VCAP_SERVICES) {
		// running in cloud
----------->	uri = xsenv.cfServiceCredentials('cf_elb_postgres').uri;
		console.log('+++++ in returnUriToDB');
	} else {
		console.log('+++++ running locally is not supported');
	}
	return uri;
}

Furthermore I don't know, if I have to adapt the resource in my mta.yaml:

- name: cf_elb_postgres
    type: postgresql

The error when trying to load data says:

[...] The following problem occurred: error - Error accessing ObjectGroups Table or DB: {"errno":"ENOTFOUND","code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"postgresql","host":"postgresql","port":5432},500,Internal Server Error

Seems as if hostname has not the right parameter of the credentials?

Best regards!

Accepted Solutions (1)

Accepted Solutions (1)

former_member603667
Participant
0 Kudos

Solved it by copying the form of the uri of the deprecated postgres-services instead of the one in the blog post: Form: "uri": "postgres://username:pw@hostname:port/dbname"

Hi Paige Ola

You could choose to configure the connection parameters based on your requirement, in the blog I have chosen to use JDBC connection URI for my java application. If you are building a Node.js application you could just use the hostname and construct a suitable URI while creating the User-Provided Service.

Thanks

Suhas

Answers (0)