-
Couldn't load subscription status.
- Fork 20
Description
Carter (@crtr0) found a bug in the way the --override flag works. I had a look at the source code and I think I found the issue.
Current behavior
When you pass --override it will actually delete the existing service and generate a new one. The problem with this is that it will create a new URL because the number in the URL pattern: <name>-<number>-<environment>.twil.io is being changed.
plugin-rtc/src/commands/rtc/apps/video/deploy.js
Lines 21 to 23 in 9544d2b
| if (this.flags.override) { | |
| await this.twilioClient.serverless.services(appInfo.sid).remove(); | |
| console.log(`Removed app with Passcode: ${appInfo.passcode}`); |
Expected behavior
The URL stays the same and only the code is being updated.
The fix
I checked and you are using @twilio-labs/serverless-api to perform the deployment.
Lines 125 to 148 in 9544d2b
| const deployOptions = { | |
| env: { | |
| TWILIO_ACCOUNT_SID: this.twilioClient.accountSid, | |
| TWILIO_API_KEY_SID: this.twilioClient.username, | |
| TWILIO_API_KEY_SECRET: this.twilioClient.password, | |
| API_PASSCODE: pin, | |
| API_PASSCODE_EXPIRY: expiryTime, | |
| }, | |
| pkgJson: {}, | |
| serviceName: APP_NAME, | |
| functionsEnv: 'dev', | |
| functions: [ | |
| { | |
| name: 'token', | |
| path: '/token', | |
| content: fn, | |
| access: 'public', | |
| }, | |
| ], | |
| assets: assets, | |
| }; | |
| try { | |
| await serverlessClient.deployProject(deployOptions); |
Instead of passing in the serviceName for the redeployment you should pass in serviceSid as shown here:
https://github.com/twilio-labs/serverless-api/blob/ee1c171113f9bd3368cbdd82b0f2cf4fee5c8f1c/src/client.ts#L382-L392
This will cause a redeployment to the same service and remove the need for deleting the service. It will also keep the same URL.