twilio / twilio-cli

Unleash the power of Twilio from your command prompt
MIT License
161 stars 79 forks source link

twilio-run doesn't resolve credentials from environment variables as documented. #586

Closed lamontadams closed 4 months ago

lamontadams commented 6 months ago

Issue Summary

I am trying to source credentials from environment variables for a CI/CD environment. Following documentation here: https://www.twilio.com/docs/twilio-cli/general-usage/profiles#use-environment-variables It seems that I should be able to define as below:

TWILIO_ACCOUNT_SID=xxxx
TWILIO_API_KEY=yyyy
TWILIO_API_SECRET=zzzz

with values sourced from the Twilio console for the API key in question. However when I do this and execute a command that requires authentication (e.g. twilio-run deploy) I receive the following error message:

│ ERROR Missing Credentials
│ 
│ We couldn't find any Twilio credentials for you.
│ 
│ Please enter ACCOUNT_SID and AUTH_TOKEN in your .env file.
│ 
│ Alternatively you can specify them via the command-line using "--username" and "--password"
│ 
│ For more information use "--help"

Edit: This doesn't seem to work when they are saved in a twilio.env file either, as implied by https://www.twilio.com/docs/usage/secure-credentials#mac--linux.

So what's the correct way to source these from the environment? Can I trust any of the documentation here? What's the recommendation for authenticating in a CI/CD environment if this simple stuff doesn't work?

Steps to Reproduce

As above.

Technical details:

│ ERROR Missing Credentials │ │ We couldn't find any Twilio credentials for you. │ │ Please enter ACCOUNT_SID and AUTH_TOKEN in your .env file. │ │ Alternatively you can specify them via the command-line using "--username" and "--password" │ │ For more information use "--help"

lamontadams commented 6 months ago

After some experimentation, this appears to work, assuming I am able to use a user account token and not a user-independent api key (and I'd certainly prefer to not have my automatic deployments tied to a single user's account from a security point-of-view):

twilio-run deploy --functions-folder dist/functions --assets-folder dist/assets -l debug --username $TWILIO_ACCOUNT_SID --password $TWILIO_AUTH_TOKEN

My experiments lead me to believe environment variables and .env files approaches that are documented just don't work. Is this intended?

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.