-
Notifications
You must be signed in to change notification settings - Fork 106
Add, Update, or Remove Environment Variables using Task
tmpayton edited this page Aug 12, 2024
·
9 revisions
This wiki will show you how to use the remove_env_var
and add_update_env_var
tasks to modify environment variables.
cf login -a api.fr.cloud.gov --sso
cf target -s dev
cf env <app> > old_env_var.json
cf oauth-token > token.txt
NOTE: This token will work for about four minutes before requiring another one. Also make sure the file is in the same directory that you are running the next command.
cf run-task api --command "python cli.py add_update_env_var <space> <service instance> <key> <value> '$(< token.txt)'" --name add_update_env_var
cf run-task api --command "python cli.py remove_env_var <space> <service instance> <key to remove> '$(< token.txt)'" --name remove_env_var
cf env <app>
rm old_env_var.json
These tasks requires that you pass in the space
, service instance
, your bearer token
.
-
space
: [Required] the space that you want to update -
service_instance
: [Required] the user provided service you want to update -
token
: [Required] your cf oath token generated above
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
cf run-task api --command "python cli.py add_update_env_var dev fec_creds_dev example_key 1234 '$(< token.txt)'" --name add_update_env_var
cf run-task api --command "python cli.py remove_env_var dev fec_creds_dev example_key '$(< token.txt)'" --name remove_env_var`