Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Event Bridge Scheduler #7268

Closed
1 task done
thantos opened this issue Nov 30, 2022 · 1 comment · Fixed by #8754
Closed
1 task done

feature request: Event Bridge Scheduler #7268

thantos opened this issue Nov 30, 2022 · 1 comment · Fixed by #8754
Assignees
Labels
aws:events Amazon EventBridge status: accepted Feature/enhancement request was accepted type: feature

Comments

@thantos
Copy link

thantos commented Nov 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Feature description

Support Event Bridge Scheduler and CFN Resources for the Scheduler (Schedule, ScheduleGroup).

https://aws.amazon.com/eventbridge/scheduler/

🧑‍💻 Implementation

Extend the Scheduled Rules support to one time schedules and the new API/SDK.

Anything else?

https://aws.amazon.com/eventbridge/scheduler/

@thantos thantos added status: triage needed Requires evaluation by maintainers type: feature labels Nov 30, 2022
@thantos thantos changed the title feature request: Event Bus Scheduler feature request: Event Bridge Scheduler Nov 30, 2022
@whummer whummer added the aws:events Amazon EventBridge label Dec 2, 2022
@OAFCROB
Copy link

OAFCROB commented Jun 7, 2023

For anyone Googling this and wondering how to handle this in a Dockerised local environment. Then the approach we've taken is to encapsulate the scheduler SDK calls in a wrapper service. We then simply fake that service out for the local docker environment. Hope that helps, until the feature has been implemented.

Logic to determine which service to use.

/**
 * Currently localstack does not support AWS's EventBridge Scheduler, meaning we have to fake our wrapper service out for local environment.
 * @see https://github.com/localstack/localstack/issues/7268
 */
const eventService = config.isLocal()
    ? getEventServiceFaker(logger)
    : getEventService(logger, config);

Local fake service

const service = (logger) => ({
    createScheduledEvent: async (event) => {
        logger.info(
            { event },
            'EventServiceFaker called on createScheduledEvent()'
        );
    },
    rescheduleEvent: async (event) => {
        logger.info({ event }, 'EventServiceFaker called on rescheduleEvent()');
    },
});

export default service;

Service example

import {
    SchedulerClient,
    CreateScheduleCommand,
} from '@aws-sdk/client-scheduler';

const service = (logger, config) => ({
    createScheduledEvent: async (event) => {
        logger.info({ event }, 'Attempting to schedule an event');

        try {
            const scheduler = new SchedulerClient({
                region: config.getAwsRegion(),
            });


            await scheduler.send(
                new CreateScheduleCommand({
                    /** 
                     * AWS create schedule command input object
                     * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-scheduler/interfaces/createschedulecommandinput.html 
                     */
                }
            );

            logger.error({ event }, 'Successfully scheduled an event');
        } catch (e) {
            logger.error({ event, error: e }, 'Failed to schedule an event');
        }
    },
    rescheduleEvent: async (event) => {
        logger.info({ event }, 'Attempting to reschedule an event');

        /**
         * TODO: Implement the UpdateScheduleCommand
         * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-scheduler/classes/updateschedulecommand.html
         */
    },
});

export default service;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:events Amazon EventBridge status: accepted Feature/enhancement request was accepted type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants