how can I pass values to a Cron's environment? I'm...
# help
a
how can I pass values to a Cron's environment? I'm trying to make a job that works with the DB, and thus I need to pass in the table names. Tried it like this, but doesn't seem to work:
Copy code
export default class CronStack extends sst.Stack {
   constructor(scope, id, props) {
      super(scope, id, props);

      const { tableNames } = props;

      new sst.Cron(this, "ReminderMail", {
         schedule: "rate(1 minute)",
         job: "src/participations/mailReminder.main",
         jobProps: {
            environment: {
               ...tableNames,
               // more env vars
            },
         },
      });
   }
}
r
You can define your function with env vars, and then pass that as the value to the job property
f
@Ross Coundon + 1. Yeah try something like this:
Copy code
new sst.Cron(this, "ReminderMail", {
         schedule: "rate(1 minute)",
         job: {
           function: {
             handler: "src/participations/mailReminder.main",
             environment: {
               ...tableNames,
            },
         },
      });
a
ah, very cool, thx guys
btw, how is this knowledge best acquired? I looked up the sst Cron tutorials ans API doc, but didn't really pick that possibility up
ah, never mind, I see it now, it's in the API doc after all
I just didn't understand what
_Type_ : FunctionDefinition | CronJobProps
really means