serverless-toolkit icon indicating copy to clipboard operation
serverless-toolkit copied to clipboard

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

Open josh08h opened this issue 4 years ago • 3 comments

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

josh08h avatar Jul 22 '20 10:07 josh08h

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)

vernig avatar Jul 23 '20 14:07 vernig

Thanks for this @vernig

josh08h avatar Jul 23 '20 17:07 josh08h

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

welcome[bot] avatar Aug 08 '20 01:08 welcome[bot]