Tatha
Tatha

Reputation: 1293

create a bluemix postgresql service pointing to existing instance

We have a set of SpringBoot applications being deployed in Bluemix as a service. Each Springboot app will have its own database schema. This is working fine when in the manifest file for each app we mention the properties

Now we are planning to use cloudfoundry/bluemix services and bind it to the individual app instead of passing the properties. From the bluemix console we can create a Postgresql service, but we don't get the option to point to an existing instance (created in compose) and pass the db credentials.

Can we create a service via CLI where we point it to an existing db instance and provide the credentials? If so how can we do that?

Thanks. Tatha

Upvotes: 0

Views: 164

Answers (1)

Alex da Silva
Alex da Silva

Reputation: 4590

You need to create a user provided service instance in this case. For example, create a service instance called my-postgresqldb and then bind to your applications:

$ cf cups my-postgresqldb -p '{"uri":"http://mydb.net", "port": 2000, "user":"admin", "password":"abcdefg"}'

$ cf bind-service your-application my-postgresqldb

Check the VCAP_SERVICES for your application in the Bluemix UI and you can see something like this:

 "user-provided": [
        {
            "credentials": {
                "password": "abcdefg",
                "port": 2000,
                "uri": "http://mydb.net",
                "user": "admin"
            },
            "syslog_drain_url": "",
            "label": "user-provided",
            "name": "my-postgresqldb",
            "tags": []
        }
    ]

Upvotes: 3

Related Questions