How can I read VCAP_SERVICES using VMC in cloudfoundry client?

776 views Asked by At

Can I read credentials using VMC, When I create a new service in Cloud Foundry?

3

There are 3 answers

0
dimcookies On

No, there is no such functionality in vmc (or any other cloudfoundry deploy tool). What you can do is log the contents of the environmental variable in a server startup listener (depending on the technology you are using) and afterwards read the log using the logs or files command

0
mdahlman On

If you are using Micro Cloud Foundry, then you can just SSH to the instance. Then you can see the credentials. I found this useful while developing (even when the eventual target is cloudfoundry.com).

For example:

less /var/vcap/data/dea/apps/JASPERREPORTS-SERVER-CE-0-f8799b0219bcd5e34a623c42bb5d23d8/env.log:
VMC_APP_HOST=127.0.0.1
VMC_APP_NAME=JASPERREPORTS-SERVER-CE
...
HOME=/var/vcap/data/dea/apps/JS-CE-0-f8799b0219bcd5e34a623c42bb5d23d8
no_proxy=.jaspersoft.cloudfoundry.me,127.0.0.1/8,localhost
HTTP_PROXY=
VMC_SERVICES=[{"name":"JasperServerDatabase","type":"database","vendor":"mysql","version":"5.1","tier":"free","options":{"name":"d4114c574d54145779f1e5575c306d4c7","hostname":"127.0.0.1","host":"127.0.0.1","port":3306,"user":"uxGQbYtPse5yE","username":"uxGQbYtPse5yE","password":"dOolhjtW7ZA4t"}}]
...
0
Bhagwad Jal Park On

I was able to use the "cf tunnel" command to get info about a newly created service.