twilio-labs / serverless-toolkit

CLI tool to develop, debug and deploy Twilio Functions
https://www.twilio.com/docs/labs/serverless-toolkit
MIT License
114 stars 59 forks source link

Deploying a function to multiple accounts response with Environment not found. #162

Open josh08h opened 4 years ago

josh08h commented 4 years ago

Background: I have 3 Twilio accounts setup (Staging/Pre-Prod/Prod) and I am attempting to deploy a function into all three environments.

Issue: I am seeing the following error when attempting to deploy a function to a Twilio account that is different to the details specified in the .twilio_functions file:

✖ Failed Deployment

│ ERROR Failed API Request 20404
│
│ The requested resource /Services/ZS7b2bbccc6ccd5493c67661868ce2e29a/Environments was not found
│
│ More info: https://www.twilio.com/docs/errors/20404

If the .twilio_functions file is empty and I deploy my function to Staging then it deploys successfully, creates the environment and amends the .twilio_functions file. If I then attempt to deploy the function to Pre-Prod it attempts to use the environment now stored in .twilio_functions which does not exist.

Is there any guidance on this? Thanks

vernig commented 4 years ago

Hey @josh08h the best way to achieve what you want to do is to use the -c / --config argument for twilio-run. This allows you to specify which configuration file to be used during deploy.

So for example you can have two different scrips that execute deployment to staging:

twilio-run deploy --config ./.preprod --account-sid ACXXXXX --auth-token XXXXX 

and production:

twilio-run deploy --config ./.prod --account-sid ACXXXXX --auth-token XXXXX

This will create different files for your environments as well as keeping track of the latest build.

REMEMBER to properly protect account SID and auth-token (which I'm not doing in the above examples)

josh08h commented 4 years ago

Thanks for this @vernig

welcome[bot] commented 4 years ago

Thank you so much for opening your first issue in this project! We'll try to get back to it as quickly as possible. While you are waiting...here's a random picture of a corgi (powered by dog.ceo)

picture of dog