Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to update variables #249

Closed
dkundel opened this issue Apr 26, 2021 · 3 comments
Closed

Provide a way to update variables #249

dkundel opened this issue Apr 26, 2021 · 3 comments

Comments

@dkundel
Copy link
Contributor

dkundel commented Apr 26, 2021

Right now there is no easy way to update environment variables using the Serverless Toolkit. You can do so using twilio api:serverless:... but it requires the knowledge of the Variable SID and other information.

We should provide a way to set those variables more conveniently.

Suggestion

Provide a dedicated command variables to set, get and update environment variables without having to know whether they exist or not.

Examples

Update an environment variable for dev environment from within a project using the Twilio CLI

twilio serverless:env set --key NAME --value VALUE

Update environment variables based on a .env file in production

twilio serverless:env import --env .env.prod --production

Get variables from a stage environment

twilio serverless:env get --key NAME --environment stage

Remove a variable from a specific environment using the environment SID

twilio serverless:env unset --key DEBUG --environment ZE1222222222222222222222

List all environment variables

twilio serverless:env list --show-values --service-sid ZS11111111111111111111111 --environment ZE333333333333333

Inspiration

The terms are inspired by the Netlify CLI. The only change is that we rely on --key and --value instead of positional arguments to make it more descriptive. Open for alternatives though.

@philnash
Copy link
Contributor

In Heroku the heroku config commands set env variables. They are mostly the same as here (get, set, and unset all exist). Two things that might be different:

Calling heroku config lists the environment variables, saving the need for a env:list command. Though list commands do mostly fit with the CLIs existing patterns.

When calling heroku config:set you pass the environment variables as if they were environment variables. For example:

heroku config:set NAME=value

I like being more explicit about which the key and variable is, this is just a shorter hand version than using --key and --value.

One final thing, you have the commands setup as twilio serverless:env get but wouldn't this be twilio serverless:env:get along with the rest of the CLI?

@dkundel
Copy link
Contributor Author

dkundel commented Apr 27, 2021

Yeah I think making list an explicit option is nicer. As for NAME=value I think the only thing that I think makes my version preferred is combining it with existing environment variables. For example:

twilio serverless:env set --key TWILIO_API_KEY --value $TWILIO_API_KEY

As opposed to:

twilio serverless:env set TWILIO_API_KEY=$TWILIO_API_KEY

AS for why set the commands up that way, in OClif it would absolutely be the right way but in twilio-run it would have to be twilio-run env set anyways. And right now twilio serverless:list environments works that way already.

That being said I'm happy to explore as part of this issue how we can map twilio-run env set to twilio serverless:env:set but I'm not sure it will be easy.

dkundel added a commit that referenced this issue Jun 25, 2021
This change introduces a new set of commands around retrieving and modifying environment variables
from already deployed environments.

re #249
This was referenced Jun 25, 2021
@philnash
Copy link
Contributor

philnash commented Jul 9, 2021

This is merged as of #290.

@philnash philnash closed this as completed Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants