amplify-backend
amplify-backend copied to clipboard
feat: add support for scheduling functions
Changes
Add the ability to schedule functions:
- Natural language - starts with
everythen the rest is based on the unit of time- Minutes and Hours
everyfollowed by a space then a positive whole number and eithermfor minute(s) orhfor hour(s)- Examples:
every 5morevery 1h
- Days, Weeks, Months, Years
everyfollowed by a space then eitherday,week,month, oryear- Days will always start at 00:00
- Weeks start on Sundays at 00:00
- Months start on 1st day of the month at 00:00
- Years start Jan 1st at 00:00
- Examples:
every dayorevery year
- Minutes and Hours
- Cron expression - 5 or 6 cron "parts" (year is not required) which follow Amazon EventBridge cron expressions for possible values
- What is not supported:
- JAN-DEC for months
- SUN-SAT for days of the week
- The
Lwildcard - The
#wildcard - The
Wwildcard
- What is not supported:
- An array that contains either of the above.
export const everyFiveMinutes = defineFunction({
name: 'everyFiveMinutes',
schedule: 'every 5m',
});
export const everyHour = defineFunction({
name: 'everyHour',
schedule: 'every 1h',
});
export const cronFiveThirtyDaily = defineFunction({
name: 'cronFiveThirtyDaily',
schedule: '30 17 * * *',
});
export const cronWednesdayAtNine = defineFunction({
name: 'cronWednesdayAtNine',
schedule: '0 9 * * 3',
});
export const arrayEvery = defineFunction({
name: 'arrayEvery',
schedule: [
'every 4h',
'every 40m'
],
});
export const arrayCron = defineFunction({
name: 'arrayCron',
schedule: [
'25 * * * *',
'* 3 * * *',
'0 1 * * * *',
],
});
export const arrayMixed = defineFunction({
name: 'arrayMixed',
schedule: [
'every 6h',
'* 5 * * *',
],
});
Validation
Unit tests to be added.
Checklist
- [ ] If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
- [ ] If this PR requires a change to the Project Architecture README, I have included that update in this PR.
- [ ] If this PR requires a docs update, I have linked to that docs PR above.
- [ ] If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the
run-e2elabel set.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
🦋 Changeset detected
Latest commit: ca2d0bd1eb466fc5752cb4b830375af273372dec
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @aws-amplify/backend-function | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR