issues running multiple stages in the same AWS account
I have two stages in my AWS account, prod, stage. When I create multiple chromeless sessions using the stage URL and API key, somehow lambdas from both prod and stage are processing my chromeless interactions. My guess is that the IOT event SQL:
SELECT * FROM 'chrome/new-sessionSELECT * FROM 'chrome/last-will
are not limiting results by stage, because when I look at messages in the chrome/new-session topic I don't see any properties related to stage.
@pklingem D'oh. You're absolutely right. Quickest solution I can think of is to simply scope the IoT topic to include the stage, e.g. prod/chrome/new-session. Might be able as use-case for the AWS IoT "Thing" ...thing.
We just ran into this issue. Posting here so that maybe it will help someone else.
We updated at line 89 chromeless/node_modules/chromeless/dist/src/chrome/remote.js
let customSessionEnv = ''
if (process.env['CHROMELESS_SESSION_ENV']) {
customSessionEnv = process.env['CHROMELESS_SESSION_ENV'] + '/'
}
this.TOPIC_NEW_SESSION = customSessionEnv + 'chrome/new-session'
and then in block at line 96
topic: customSessionEnv + 'chrome/last-will',
Update the iot portion of serverless.yml to something like the following :+1:
SELECT * FROM 'dev/chrome/new-session
SELECT * FROM 'dev/chrome/last-will
SELECT * FROM 'prod/chrome/new-session
SELECT * FROM 'prod/chrome/last-will
This works like a charm and we now have working dev and prod to the same iot gateway.
We opt'd for environment variable as our code is called via celery and we set accordingly at celery startup. But should give you the idea.
Ran into the same issue, after playing around a bit I was able to hack the queries into submission!
"SELECT * FROM 'chrome/new-session' WHERE endswith(options.remote.endpointUrl, '/${self:custom.stage}/')"
"SELECT * FROM 'chrome/last-will' WHERE endswith(options.remote.endpointUrl, '/${self:custom.stage}/')"
This takes advantage of the fact that the endpointUrl is passed to the events and it ends with /{stage}/.