Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set environment variables on Cloud Foundry v2?

I need to set up consumer key and secrets for Github, Twitter and Facebook.

On version 1 of Cloud Foundry you could do vmc env-add NAME=VALUE Now with the cf gem I see I can do cf env but thats it. I also tried setting a .env file and repushing with no success

like image 627
Monica Wilkinson Avatar asked Jul 27 '13 21:07

Monica Wilkinson


People also ask

How do I check environment variables in Cloud Foundry?

Using the Cloud Foundry Command Line Interface (cf CLI), you can run the cf env command to view the Cloud Foundry environment variables for your app. The cf env command displays the following environment variables: The VCAP_APPLICATION and VCAP_SERVICES variables provided in the container environment.

How do you set environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

How do I change environment variables in PCF?

You can modify environment variables associated with an application while the application is running using the cf set-env (to set or update) and cf unset-env (to delete). This will update the environment variable in Cloud Controller at the time you run the command.


2 Answers

In addition, you can set environment variables in an application manifest file.

Here is an example of how to do so (see the env section of the manifest with name/value pairs)

---
applications:
- name: app1
  env:
    ENV_VAR_1: MYVALUE
    ENV_VAR_2: ZZZ
like image 195
Andy Piper Avatar answered Oct 10 '22 07:10

Andy Piper


It looks like you can do a cf set-env (https://github.com/cloudfoundry/cf/blob/master/lib/cf/cli/app/env.rb). You can also always do a cf help --all, which will show you all the commands you can use.

like image 37
Amit Kumar Gupta Avatar answered Oct 10 '22 08:10

Amit Kumar Gupta