mitipi / serverless-ngrok-tunnel

Serverless plugin that creates ngrok public tunnel on localhost.
MIT License
9 stars 9 forks source link

Tunnel URL environment variable is not being picked up by `serverless-dotenv-plugin` #5

Open DonIsaac opened 3 years ago

DonIsaac commented 3 years ago

The Issue

I'm trying to have serverless-ngrok-tunnel write to an env file so that it may be picked up by serverless-dotenv-plugin. Unfortunately, serverless-dotenv-plugin reads in the env file before the tunnel is connected and therefore before the env file is modified.

Changing the plugin order has no effect. Different values for dotEnv do nothing, including omitting it.

Settings

Serverless Plugins ```typescript // ... plugins: [ "serverless-webpack", "serverless-dynamodb-local", "serverless-offline", "serverless-ngrok-tunnel", "serverless-dotenv-plugin", ] // ... ```
Ngrok Tunnel Settings ```typescript ngrokTunnel: { "envPath": ".env.local", "tunnels": [ { port: 3000, envProp: "NGROK_TUNNEL_URL", ngrokOptions: { "region": "us", } } ] }, ```

The command I'm running:

sls offline start -s local --printOutput --tunnel=true

Side note: tunneling does not work with sls offline ..., only with sls offline start ...

The verbose logs:

Verbose output with `SLS_DEBUG=*` ``` $ sls offline start -s local --printOutput --tunnel=true Serverless: Load command interactiveCli Serverless: Load command config Serverless: Load command config:credentials Serverless: Load command config:tabcompletion Serverless: Load command config:tabcompletion:install Serverless: Load command config:tabcompletion:uninstall Serverless: Load command create Serverless: Load command install Serverless: Load command package Serverless: Load command deploy Serverless: Load command deploy:function Serverless: Load command deploy:list Serverless: Load command deploy:list:functions Serverless: Load command invoke Serverless: Load command invoke:local Serverless: Load command info Serverless: Load command logs Serverless: Load command metrics Serverless: Load command print Serverless: Load command remove Serverless: Load command rollback Serverless: Load command rollback:function Serverless: Load command slstats Serverless: Load command plugin Serverless: Load command plugin Serverless: Load command plugin:install Serverless: Load command plugin Serverless: Load command plugin:uninstall Serverless: Load command plugin Serverless: Load command plugin:list Serverless: Load command plugin Serverless: Load command plugin:search Serverless: Load command config Serverless: Load command config:credentials Serverless: Load command rollback Serverless: Load command rollback:function Serverless: Load command upgrade Serverless: Load command uninstall Serverless: Load command webpack Serverless: Load command dynamodb Serverless: Load command dynamodb:migrate Serverless: Load command dynamodb:seed Serverless: Load command dynamodb:start Serverless: Load command dynamodb:noStart Serverless: Load command dynamodb:remove Serverless: Load command dynamodb:install Serverless: Load command offline Serverless: Load command offline:start Serverless: Load command tunnel Serverless: envVars: {} # Logged in serverless-dotenv-plugin in `loadEnv` right after `parseEnvFiles` was called Serverless: DOTENV: Loading environment variables from .env.local, .env.local: Serverless: Load command login Serverless: Load command logout Serverless: Load command generate-event Serverless: Load command test Serverless: Load command dashboard Serverless: Load command output Serverless: Load command output:get Serverless: Load command output:list Serverless: Load command param Serverless: Load command param:get Serverless: Load command param:list Serverless: Load command studio platform-sdk fetching: POST https://api.serverless.com/core/tenants/[OMITTED] Serverless: Invoke offline:start Serverless: Invoke webpack:validate serverless options: {"s":"local","printOutput":true,"tunnel":"true","stage":"local"} is dev: true Serverless: Bundling with Webpack... Serverless: Webpack watch invoke: HASH NEW=eed6591b134cc2b6969c CUR=null asset src_lib_index_ts.js 14.2 KiB [emitted] 1 related asset asset src/handlers/lifecycle.js 12.1 KiB [emitted] (name: src/handlers/lifecycle) 1 related asset asset src/handlers/proxy.js 11.3 KiB [emitted] (name: src/handlers/proxy) 1 related asset asset src/handlers/plugin.js 8.31 KiB [emitted] (name: src/handlers/plugin) 1 related asset asset src/handlers/page.js 2.01 KiB [emitted] (name: src/handlers/page) 1 related asset Entrypoint src/handlers/plugin 22.5 KiB (37 KiB) = src_lib_index_ts.js 14.2 KiB src/handlers/plugin.js 8.31 KiB 2 auxiliary assets Entrypoint src/handlers/proxy 25.5 KiB (44.1 KiB) = src_lib_index_ts.js 14.2 KiB src/handlers/proxy.js 11.3 KiB 2 auxiliary assets Entrypoint src/handlers/page 2.01 KiB (1.89 KiB) = src/handlers/page.js 1 auxiliary asset Entrypoint src/handlers/lifecycle 26.3 KiB (47.3 KiB) = src_lib_index_ts.js 14.2 KiB src/handlers/lifecycle.js 12.1 KiB 2 auxiliary assets cached modules 25.1 KiB (javascript) 4.92 KiB (runtime) [cached] 38 modules webpack compiled successfully in 308 ms Serverless: Watching for changes... Dynamodb Local Started, Visit: http://localhost:8000/shell 2021-02-09 13:06:17.799:INFO::main: Logging initialized @700ms to org.eclipse.jetty.util.log.StdErrLog Serverless: DynamoDB - created table wafir-backend-local Serverless: Starting tunnels... offline: Starting Offline: dev/us-east-1. [offline] options: { apiKey: 'd41d8cd98f00b204e9800998ecf8427e', corsAllowCredentials: true, corsAllowHeaders: [ 'accept', 'content-type', 'x-api-key', 'authorization' ], corsAllowOrigin: [ '*' ], corsExposedHeaders: [ 'WWW-Authenticate', 'Server-Authorization' ], disableCookieValidation: false, enforceSecureCookies: false, hideStackTraces: false, host: 'localhost', httpPort: 3000, httpsProtocol: '', lambdaPort: 3002, noPrependStageInUrl: false, noAuth: false, noTimeout: false, prefix: '', printOutput: true, resourceRoutes: false, useChildProcesses: true, useWorkerThreads: false, websocketPort: 3001, webSocketHardTimeout: 7200, webSocketIdleTimeout: 600, useDocker: false, layersDir: null, dockerReadOnly: true, functionCleanupIdleTimeSeconds: 60, allowCache: false, location: '.webpack/service', s: 'local', tunnel: 'true', stage: 'local', region: undefined, corsConfig: { credentials: true, exposedHeaders: [ 'WWW-Authenticate', 'Server-Authorization' ], headers: [ 'accept', 'content-type', 'x-api-key', 'authorization' ], origin: [ '*' ] } } offline: Offline [http for lambda] listening on http://localhost:3002 offline: Function names exposed for local invocation by aws-sdk: * config: backend-local-config * proxy: backend-local-proxy * pageConfig: backend-local-pageConfig * installed: backend-local-installed * uninstalled: backend-local-uninstalled * enabled: backend-local-enabled [offline] Lambda Invocation Routes (for AWS SDK or AWS CLI): * POST http://localhost:3002/2015-03-31/functions/backend-local-config/invocations * POST http://localhost:3002/2015-03-31/functions/backend-local-proxy/invocations * POST http://localhost:3002/2015-03-31/functions/backend-local-pageConfig/invocations * POST http://localhost:3002/2015-03-31/functions/backend-local-installed/invocations * POST http://localhost:3002/2015-03-31/functions/backend-local-uninstalled/invocations * POST http://localhost:3002/2015-03-31/functions/backend-local-enabled/invocations [offline] Lambda Async Invocation Routes (for AWS SDK or AWS CLI): * POST http://localhost:3002/2014-11-13/functions/backend-local-config/invoke-async/ * POST http://localhost:3002/2014-11-13/functions/backend-local-proxy/invoke-async/ * POST http://localhost:3002/2014-11-13/functions/backend-local-pageConfig/invoke-async/ * POST http://localhost:3002/2014-11-13/functions/backend-local-installed/invoke-async/ * POST http://localhost:3002/2014-11-13/functions/backend-local-uninstalled/invoke-async/ * POST http://localhost:3002/2014-11-13/functions/backend-local-enabled/invoke-async/ ┌───────────────────────────────────────────────────────────────────────────────┐ │ │ │ GET | http://localhost:3000/local/atlassian-connect.json │ │ POST | http://localhost:3000/2015-03-31/functions/config/invocations │ │ ANY | http://localhost:3000/local/api │ │ POST | http://localhost:3000/2015-03-31/functions/proxy/invocations │ │ ANY | http://localhost:3000/local/api/{any*} │ │ POST | http://localhost:3000/2015-03-31/functions/proxy/invocations │ │ GET | http://localhost:3000/local/page/config │ │ POST | http://localhost:3000/2015-03-31/functions/pageConfig/invocations │ │ POST | http://localhost:3000/local/installed │ │ POST | http://localhost:3000/2015-03-31/functions/installed/invocations │ │ POST | http://localhost:3000/local/uninstalled │ │ POST | http://localhost:3000/2015-03-31/functions/uninstalled/invocations │ │ POST | http://localhost:3000/local/enabled │ │ POST | http://localhost:3000/2015-03-31/functions/enabled/invocations │ │ POST | http://localhost:3000/local/disabled │ │ POST | http://localhost:3000/2015-03-31/functions/enabled/invocations │ │ │ └───────────────────────────────────────────────────────────────────────────────┘ offline: [HTTP] server ready: http://localhost:3000 🚀 offline: offline: Enter "rp" to replay the last request Serverless: NGROK_TUNNEL_URL available at: https://6fb9085947aa.ngrok.io ```
DonIsaac commented 3 years ago

@nenadpnc Any updates on this?