Skip to content

Add, Update, or Remove Environment Variables using Task

tmpayton edited this page Apr 3, 2025 · 10 revisions

This wiki will show you how to use the remove_env_var and add_update_env_var task to modify environment variables.

Note: This task can only be run locally

1. Login to cloud.gov:

cf login -a api.fr.cloud.gov  --sso

2. Dump old environment variables into a file:

cf env <app> > old_env_var.json

3. Navigate to your local openFEC repo and start your virtual environment

4. Ensure the SLACK_HOOK environment variable is set:

export SLACK_HOOK=<XXXX>

5. Modify the environment variable:

To add or update an environment variable:

python cli.py add_update_env_var <space> <service instance> <key> <value>

To remove an environment variable:

python cli.py remove_env_var <space> <service instance> <key to remove>

6. Confirm changes took with

cf env <app>

7. Rebuild the app in CircleCI

8. Delete the old environment variables

rm old_env_var.json

Task arguments:

These tasks requires that you pass in the space and service instance.

  • space: [Required] the space that you want to update
  • service_instance: [Required] the user provided service you want to update

For adding or updating environment variables you must pass in the key value pair:

  • key: [Required] The key of the environment variable you would like to add or update
  • value: [Required] The value of the environment variable you would like to add or update

For removing an environment variable you must also pass in the key to remove:

  • key_to_remove: [Required] The key of the environment variable you would like to remove

Add/update example:

python cli.py add_update_env_var dev fec-service-instance example_key 1234

remove example:

python cli.py remove_env_var dev fec-service-instance example_key
Clone this wiki locally