sumitavo biswas
03/26/2022, 12:38 PMRobert Banaszak
03/26/2022, 12:50 PMthis.cronJob = new sst.Cron(this, "bitbucket-scheduler-cron", {
schedule: "rate(5 minutes)",
job: {
function: "src/bitbucket-api/scheduler.main",
jobProps: {
environment: {
testprop: this.bitbucketJobTable.dynamodbTable.tableName,
},
},
},
});
Robert Banaszak
03/26/2022, 12:50 PMRobert Banaszak
03/26/2022, 12:56 PMstring
as path to the function, create new instance of Function
and pass env thereRobert Banaszak
03/26/2022, 12:57 PMthis.cronJob = new sst.Cron(this, "bitbucket-scheduler-cron", {
schedule: "rate(5 minutes)",
job: {
function: new Function(this, "SchedulerFunction", {
handler: "src/bitbucket-api/scheduler.main",
environment: {
testprop: this.bitbucketJobTable.dynamodbTable.tableName,
},
}),
},
});
if I got it correctlysumitavo biswas
03/26/2022, 1:01 PMsumitavo biswas
03/26/2022, 1:07 PMSyntaxError: Arg string terminates parameters early
at new Function (<anonymous>)
this.cronJob = new sst.Cron(this, "bitbucket-scheduler-cron", {
schedule: "rate(5 minutes)",
job: {
function: new Function(this, "bitbucket-scheduler", {
handler: "src/bitbucket-api/scheduler.main",
timeout: 60,
environment: {
bitbucketScheduleJobTableName:
this.bitbucketScheduleJobTable.dynamodbTable.tableName,
bitbucketScheduleJobUserIdIndexName: "scheduleuserCreatedDateIndex",
scheduleJobIdIndexName: "jobIdCreatedDateIndex",
bitbucketJobTableName:
this.bitbucketJobTable.dynamodbTable.tableName,
bitbucketJobUserIdIndexName: "userCreatedDateIndex",
identifierIndexName: "identifierCreatedDateIndex",
},
}),
},
});Ashishkumar Pandey
03/26/2022, 1:14 PMsumitavo biswas
03/26/2022, 1:20 PMAshishkumar Pandey
03/26/2022, 1:22 PMnew Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: {
function: {
handler: 'src/lambda.js',
environment: {
hello: process.env.hello
}
},
},
});
Robert Banaszak
03/26/2022, 1:23 PMFunction
from sst
?
Alternatively:
const bitbucketSchedulerFunction = new sst.Function(
this,
"bitbucket-scheduler-cron",
{
handler: "src/bitbucket-api/scheduler.main",
environment: {
testprop: this.bitbucketJobTable.dynamodbTable.tableName,
},
}
);
this.cronJob = new sst.Cron(this, "bitbucket-scheduler-cron", {
schedule: "rate(5 minutes)",
job: {
function: bitbucketSchedulerFunction,
},
});
Ashishkumar Pandey
03/26/2022, 1:24 PMRobert Banaszak
03/26/2022, 1:28 PMFrank
new Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: {
function: {
handler: 'src/lambda.js',
environment: {
hello: process.env.hello
}
},
},
});
And this
const fn = new Function(this, "Fn", {
handler: 'src/lambda.js',
environment: {
hello: process.env.hello
}
});
new Cron(this, "Cron", {
schedule: "rate(1 minute)",
job: {
function: fn,
},
});
Frank
Cron
will create the Function
internally.Ashishkumar Pandey
03/26/2022, 1:37 PMRobert Banaszak
03/26/2022, 1:38 PMAshishkumar Pandey
03/26/2022, 1:38 PMFrank
so, is using a new function instance as the value for the function key a valid approach as well?Yeah it is. Mostly unnecessary, useful when sharing a function across ie. multiple Api routes.
Ashishkumar Pandey
03/26/2022, 2:38 PMRoss Coundon
03/26/2022, 6:41 PM