I have a single function definition that can be in...
# sst
r
I have a single function definition that can be included in a stack multiple times with different names.
Copy code
datasetIds.forEach((datasetId) => {
      
      const populatorFunction = new sst.Function(this, `populatorFunction-${datasetId}`, {
        handler: 'src/main/handler/populator.startLookingForMissingUrls',
        environment: {
          OFSC_INSTANCE: datasetId,
        },
      });

      new sst.Cron(this, `OmwPopulatorCron=${datasetId}`, {
        schedule: process.env.POPULATOR_CRON,
        job: {
          function: populatorFunction,
        },
      });
})
So you can see that the OFSC_INSTANCE env var is set according to the value from a string array defined earlier. When running this using
sst start
I'm seeing some odd behaviour regarding the env var OFSC_INSTANCE. On the first kick off of each lambda via the cron, sometimes the value of the env var is correct. However, after that, both lambdas have the same value for that env var. Sometimes they're the same on first start too. Is there something about the local execution environment that would env vars end up getting shared between invocations of shared code?
t
Yeah I think we hash the handler src in the new system to determine if a function is unique. I need a better way to hash it, will make an issue