diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/.gitignore b/eventbridge-schedule-remove-one-time-schedules-cdk-python/.gitignore
new file mode 100644
index 000000000..7fa5e4d40
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/.gitignore
@@ -0,0 +1,11 @@
+*.swp
+package-lock.json
+__pycache__
+.pytest_cache
+.env
+.venv
+*.egg-info
+
+# CDK asset staging directory
+.cdk.staging
+cdk.out
\ No newline at end of file
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/README.md b/eventbridge-schedule-remove-one-time-schedules-cdk-python/README.md
new file mode 100644
index 000000000..d77b8592d
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/README.md
@@ -0,0 +1,62 @@
+# Remove completed Amazon EventBridge Schedules and sent notification using Amazon SNS
+
+This pattern will create an Amazon EventBridge Scheduler and will run every five minutes and will use AWS Lambda to identify expired and completed Amazon Evenbridge Scheduler tasks that are expired 7 days or more and will send an SNS notification once the activity is completed. The pattern is deployed using the AWS Cloud Development Kit (AWS CDK) for Python.
+
+Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
+
+## Requirements
+
+* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one
+ and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS
+ resources.
+* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured
+* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
+* [AWS CDK Toolkit](https://docs.aws.amazon.com/cdk/latest/guide/cli.html) installed and configured
+* [Python 3.9+](https://www.python.org/downloads/) installed
+
+## Deployment Instructions
+
+1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
+ ```
+ git clone https://github.com/aws-samples/serverless-patterns
+ ```
+2. Change directory to the pattern directory:
+ ```
+ cd eventbridge-schedule-remove-one-time-schedules-cdk-python
+ ```
+3. From the command line, bootstrap the CDK if you haven't already done so.
+ ```
+ cdk bootstrap
+ ```
+4. Install the Python required dependencies:
+ ```
+ pip install -r requirements.txt
+ ```
+5. Deploy the CDK stack to your default AWS account and region.
+ ```
+ cdk deploy
+ ```
+6. Add your email as subscription to SNS after replacing "YOURSNSTOPICARN" and "YOUREMAIL" in the command below
+ ```
+ aws sns subscribe --topic-arn YOURSNSTOPICARN --protocol email --notification-endpoint YOUREMAIL
+ ```
+## How it works
+
+An Amazon EventBridge Scheduler job runs every five minutes and will use AWS lambda to identify and delete one time Amazon EventBridge Scheduler jobs expired more than 7 days.Scheduler job also sends a SNS notifications to confirm the activity is completed.
+Along with a schedule and topic, the CDK stack creates an IAM role and policy for Amazon EventBridge Scheduler to assume and send messages.
+
+## Testing
+After the stack has been deployed, you can verify Amazon EventBridge is successfully publishing to the topic by viewing the topics "NumberOfMessagesPublished" metric in CloudWatch and verifying positive data points.
+
+You can also add a subscription to the SNS topic such as an email address or phone number to verify messages are being published successfully.
+
+## Cleanup
+
+1. Delete the stack
+ ```bash
+ cdk destroy
+ ```
+----
+Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+SPDX-License-Identifier: MIT-0
\ No newline at end of file
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/app.py b/eventbridge-schedule-remove-one-time-schedules-cdk-python/app.py
new file mode 100644
index 000000000..725c7ed9a
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/app.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+import aws_cdk as cdk
+
+from eventbridge_schedule_remove_onetime_schedules_cdk_python.eventbridge_schedule_remove_onetime_schedules_cdk_python_stack import EventBridgeRemoveOnetimeSchedulesCdkPythonStack
+
+app = cdk.App()
+EventBridgeRemoveOnetimeSchedulesCdkPythonStack(app, "EventBridgeRemoveOnetimeSchedulesCdkPythonStack")
+
+app.synth()
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/cdk.json b/eventbridge-schedule-remove-one-time-schedules-cdk-python/cdk.json
new file mode 100644
index 000000000..c82273b0a
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/cdk.json
@@ -0,0 +1,48 @@
+{
+ "app": "python3 app.py",
+ "watch": {
+ "include": [
+ "**"
+ ],
+ "exclude": [
+ "README.md",
+ "cdk*.json",
+ "requirements*.txt",
+ "source.bat",
+ "**/__init__.py",
+ "python/__pycache__",
+ "tests"
+ ]
+ },
+ "context": {
+ "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
+ "@aws-cdk/core:checkSecretUsage": true,
+ "@aws-cdk/core:target-partitions": [
+ "aws",
+ "aws-cn"
+ ],
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
+ "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
+ "@aws-cdk/aws-iam:minimizePolicies": true,
+ "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
+ "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
+ "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
+ "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
+ "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
+ "@aws-cdk/core:enablePartitionLiterals": true,
+ "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
+ "@aws-cdk/aws-iam:standardizedServicePrincipals": true,
+ "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
+ "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
+ "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
+ "@aws-cdk/aws-route53-patters:useCertificate": true,
+ "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
+ "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
+ "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
+ "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
+ "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
+ "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
+ "@aws-cdk/aws-redshift:columnId": true
+ }
+ }
\ No newline at end of file
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge-schedule-remove-one-time-schedules-cdk-python.json b/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge-schedule-remove-one-time-schedules-cdk-python.json
new file mode 100644
index 000000000..32b97ab16
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge-schedule-remove-one-time-schedules-cdk-python.json
@@ -0,0 +1,87 @@
+{
+ "title": "Amazon EventBridge Scheduler remove one time schedule",
+ "description": "Amazon EventBridge Scheduler job runs every five minutes to identify and delete one time Amazon EventBridge Scheduler jobs expired more than 7 days.",
+ "language": "Python",
+ "level": "300",
+ "framework": "CDK",
+ "introBox": {
+ "headline": "How it works",
+ "text": [
+ "Amazon EventBridge Scheduler job runs every five minutes and uses AWS Lambda to identify and delete one time Scheduler jobs that are expired more than 7 days",
+ "Scheduler job uses Amazon Simple Notification Service to send email notification once the activity is complete.",
+ "This pattern deploys AWS Lambda, Amazon EventBridge Scheduler(one recurring ,and two one-time jobs) and Amazon Simple Notification Service"
+ ]
+ },
+ "gitHub": {
+ "template": {
+ "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/eventbridge-schedule-remove-onetime-schedule-to-sns-cdk-python",
+ "templateURL": "serverless-patterns/eventbridge-schedule-remove-one-time-schedule-to-sns-cdk-python",
+ "projectFolder": "eventbridge-schedule-remove-one-time-schedules-cdk-python",
+ "templateFile": "eventbridge_schedule_remove_onetime_schedules_cdk_python/eventbridge_schedule_remove_onetime_schedules_cdk_python_stack.py"
+ }
+ },
+ "resources": {
+ "bullets": [
+ {
+ "text": "Eventbridge Schedueler one time schedule",
+ "link": "https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html"
+ },
+ {
+ "text": "Amazon Eventbridge Scheduler - Scheduler to run and manage tasks ",
+ "link": "https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html"
+ }
+ ]
+ },
+ "deploy": {
+ "text": [
+ "cdk deploy"
+ ]
+ },
+ "testing": {
+ "text": [
+ "See the GitHub repo for detailed testing instructions."
+ ]
+ },
+ "cleanup": {
+ "text": [
+ "Delete the stack: cdk delete
."
+ ]
+ },
+ "authors": [
+ {
+ "name": "Manikandan Karimanal",
+ "image": "https://drive.google.com/file/d/16r4jGGMpPhu4Igez-lzstIe-L5nJVMxf/view",
+ "bio": "Solution Architect @AWS",
+ "linkedin": "manikandanks"
+ }
+ ],
+ "patternArch": {
+ "icon1": {
+ "x": 20,
+ "y": 50,
+ "service": "eventbridge-scheduler",
+ "label": "Amazon EventBridge Scheduler"
+ },
+ "icon2": {
+ "x": 50,
+ "y": 50,
+ "service": "lambda",
+ "label": "AWS Lambda"
+ },
+ "icon3": {
+ "x": 80,
+ "y": 50,
+ "service": "sns",
+ "label": "Amazon SNS"
+ },
+ "line1": {
+ "from": "icon1",
+ "to": "icon2",
+ "label": "cron (5 minutes)"
+ },
+ "line2": {
+ "from": "icon2",
+ "to": "icon3"
+ }
+ }
+}
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge_schedule_remove_onetime_schedules_cdk_python/__init__.py b/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge_schedule_remove_onetime_schedules_cdk_python/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge_schedule_remove_onetime_schedules_cdk_python/eventbridge_schedule_remove_onetime_schedules_cdk_python_stack.py b/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge_schedule_remove_onetime_schedules_cdk_python/eventbridge_schedule_remove_onetime_schedules_cdk_python_stack.py
new file mode 100644
index 000000000..3dca17075
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/eventbridge_schedule_remove_onetime_schedules_cdk_python/eventbridge_schedule_remove_onetime_schedules_cdk_python_stack.py
@@ -0,0 +1,133 @@
+from aws_cdk import (
+ CfnOutput,
+ Duration,
+ Stack,
+ aws_iam as iam,
+ aws_sns as _sns,
+ aws_sns_subscriptions as snssubscriptions,
+ aws_sqs as sqs,
+ aws_scheduler as scheduler,
+ aws_ec2 as ec2,
+ aws_lambda as _lambda,
+ aws_events as events,
+)
+from constructs import Construct
+
+#use everybridge scheduler that runs every 5 minutes to remove one time eventbridge schedules completed and not used
+#add lambda to sns subscription
+
+class EventBridgeRemoveOnetimeSchedulesCdkPythonStack(Stack):
+
+ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
+ super().__init__(scope, construct_id, **kwargs)
+
+ ## Create SNS Topic
+ my_sns_topic = _sns.Topic(self, "my-sns-topic")
+
+ #subscribe an email to the sns topic (optional to replace command like option)
+ # my_sns_topic.add_subscription(snssubscriptions.EmailSubscription("EMAIL-XXX"))
+
+ ## Create schedule role
+ scheduler_role = iam.Role(self, "scheduler-role",
+ assumed_by=iam.ServicePrincipal("scheduler.amazonaws.com")
+ )
+
+ ## Create IAM policy
+ scheduler_events_policy = iam.PolicyStatement(
+ actions=["sns:Publish","lambda:InvokeFunction"],
+ resources=[my_sns_topic.topic_arn],
+ effect=iam.Effect.ALLOW,
+ )
+
+
+
+ ## Add IAM policy to schedule role
+ scheduler_role.add_to_policy(scheduler_events_policy)
+
+ scheduled_event_remover_lambda = _lambda.Function(self, "scheduledEventRemoverLambda",
+ runtime=_lambda.Runtime.PYTHON_3_9,
+ handler="scheduled_event_remover_lambda.lambda_handler",
+ code=_lambda.Code.from_asset("lambda"),
+ environment={'TOPIC_ARN': my_sns_topic.topic_arn},
+ timeout = Duration.seconds(600)
+ )
+
+ #add lambda to sns topic
+ my_sns_topic.grant_publish(scheduled_event_remover_lambda)
+
+ event_policy = iam.PolicyStatement(effect=iam.Effect.ALLOW, resources=['*'], actions=['scheduler:*','sns:Publish'])
+ scheduled_event_remover_lambda.add_to_role_policy(event_policy)
+
+ ## Create IAM policy
+ scheduler_scheduled_events_policy = iam.PolicyStatement(
+ actions=["lambda:InvokeFunction"],
+ resources=[scheduled_event_remover_lambda.function_arn],
+ effect=iam.Effect.ALLOW,
+ )
+
+ scheduler_role.add_to_policy(scheduler_scheduled_events_policy)
+
+ my_schedule_scheduled = scheduler.CfnSchedule(self, "my-schedule-scheduled",
+ flexible_time_window=scheduler.CfnSchedule.FlexibleTimeWindowProperty(
+ mode="OFF",
+ ),
+
+ schedule_expression="cron(0/5 * * * ? *)",
+ schedule_expression_timezone="America/New_York",
+ target=scheduler.CfnSchedule.TargetProperty(
+ arn=scheduled_event_remover_lambda.function_arn,
+ role_arn=scheduler_role.role_arn,
+ input="{\"key\":\"my-schedule\"}"
+ )
+
+ )
+
+
+
+ # Create schedule to send a message to SNS once on a specific time
+ my_schedule_onetime1 = scheduler.CfnSchedule(self, "my-schedule-onetime1",
+ flexible_time_window=scheduler.CfnSchedule.FlexibleTimeWindowProperty(
+ mode="OFF",
+ ),
+ schedule_expression="at(2023-10-10T11:47:00)",
+ schedule_expression_timezone="America/New_York",
+ target=scheduler.CfnSchedule.TargetProperty(
+ arn=my_sns_topic.topic_arn,
+ role_arn=scheduler_role.role_arn,
+ input="{\"key\":\"my-schedule-onetime1 removed\"}"
+ )
+
+ )
+
+
+ # Create schedule to send a message to SNS once on a specific time
+ my_schedule_onetime2 = scheduler.CfnSchedule(self, "my-schedule-onetime2",
+ flexible_time_window=scheduler.CfnSchedule.FlexibleTimeWindowProperty(
+ mode="OFF",
+ ),
+ schedule_expression="at(2023-10-10T11:47:00)",
+ schedule_expression_timezone="America/New_York",
+ target=scheduler.CfnSchedule.TargetProperty(
+ arn=my_sns_topic.topic_arn,
+ role_arn=scheduler_role.role_arn,
+ input="{\"key\":\"my-schedule-onetime2 removed\"}"
+ )
+
+ )
+
+
+ environment={ # ADD THIS, FILL IT FOR ACTUAL VALUE
+ "mysns_topic_arn": my_sns_topic.topic_arn,
+ "testname": "testvalue"
+ }
+
+
+
+ ## CloudFormation Stack Outputs
+ CfnOutput(self, "LAMBDA_REMOVE_SCHEDULED_EVENTS", value=scheduled_event_remover_lambda.function_arn)
+ CfnOutput(self, "SCHEDULE_NAME", value=my_schedule_scheduled.ref)
+ CfnOutput(self, "SCHEDULE_ONETIMENAME1", value=my_schedule_onetime1.ref)
+ CfnOutput(self, "SCHEDULE_ONETIMENAME2", value=my_schedule_onetime2.ref)
+ CfnOutput(self, "SNS_TOPIC_NAME", value=my_sns_topic.topic_arn)
+
+
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/example-pattern.json b/eventbridge-schedule-remove-one-time-schedules-cdk-python/example-pattern.json
new file mode 100644
index 000000000..39e229d4f
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/example-pattern.json
@@ -0,0 +1,58 @@
+{
+ "title": "Amazon EventBridge Scheduler remove One time Schedule",
+ "description": "Amazon EventBridge Scheduler job runs every five minutes to identify and delete one time Amazon EventBridge Scheduler jobs expired more than 7 days.",
+ "language": "Python",
+ "level": "300",
+ "framework": "CDK",
+ "introBox": {
+ "headline": "How it works",
+ "text": [
+ "Amazon EventBridge Scheduler job runs every five minutes and uses AWS Lambda to identify and delete one time Amazon EventBridge Scheduler jobs that are expired more than 7 days",
+ "Scheduler job sends a Amazon Simple Notification Service to send email notification once the activity is completed.",
+ "This pattern deploys AWS Lambda, Amazon EventBridge Scheduler(one recurring ,and two one-time jobs) and Amazon Simple Notification Service"
+ ]
+ },
+ "gitHub": {
+ "template": {
+ "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/eventbridge-schedule-remove-onetime-schedule-to-sns-cdk-python",
+ "templateURL": "serverless-patterns/eventbridge-schedule-remove-one-time-schedule-to-sns-cdk-python",
+ "projectFolder": "eventbridge-schedule-remove-one-time-schedules-cdk-python",
+ "templateFile": "eventbridge_schedule_remove_onetime_schedules_cdk_python/eventbridge_schedule_remove_onetime_schedules_cdk_python_stack.py"
+ }
+ },
+ "resources": {
+ "bullets": [
+ {
+ "text": "Eventbridge Schedueler one time schedule",
+ "link": "https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html"
+ },
+ {
+ "text": "Amazon Eventbridge Scheduler - Scheduler to run and manage tasks ",
+ "link": "https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html"
+ }
+ ]
+ },
+ "deploy": {
+ "text": [
+ "cdk deploy"
+ ]
+ },
+ "testing": {
+ "text": [
+ "See the GitHub repo for detailed testing instructions."
+ ]
+ },
+ "cleanup": {
+ "text": [
+ "Delete the stack: cdk delete
."
+ ]
+ },
+ "authors": [
+ {
+ "name": "Manikandan Karimanal",
+ "image": "https://drive.google.com/file/d/16r4jGGMpPhu4Igez-lzstIe-L5nJVMxf/view",
+ "bio": "Solution Architect @AWS",
+ "linkedin": "manikandanks"
+ }
+ ]
+}
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/img/onetimeschedule-architecturediagram.png b/eventbridge-schedule-remove-one-time-schedules-cdk-python/img/onetimeschedule-architecturediagram.png
new file mode 100644
index 000000000..d86a0bbab
Binary files /dev/null and b/eventbridge-schedule-remove-one-time-schedules-cdk-python/img/onetimeschedule-architecturediagram.png differ
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/lambda/scheduled_event_remover_lambda.py b/eventbridge-schedule-remove-one-time-schedules-cdk-python/lambda/scheduled_event_remover_lambda.py
new file mode 100644
index 000000000..6e85fea20
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/lambda/scheduled_event_remover_lambda.py
@@ -0,0 +1,50 @@
+import json
+import logging
+import boto3
+import os
+
+
+
+import datetime
+from dateutil import parser
+
+logger = logging.getLogger()
+logger.setLevel(logging.INFO)
+logger.info('Loading function')
+sns=boto3.client('sns')
+def lambda_handler(event, context):
+ mysnstopicarn=os.environ['TOPIC_ARN']
+ print(mysnstopicarn)
+
+ scheduler=boto3.client('scheduler')
+ response = scheduler.list_schedules()
+ for schedule in response['Schedules']:
+ print(schedule)
+ print(schedule['Name'])
+ if "myscheduleonetime" in schedule['Name']:
+ print("###############################scheduler###############################")
+ print(scheduler.get_schedule(Name=schedule['Name']))
+ scheduleinfo=json.loads(json.dumps(scheduler.get_schedule(Name=schedule['Name']),indent=2, sort_keys=True, default=str))
+ print(scheduleinfo['ScheduleExpression'])
+ scheduleinfostr=json.dumps(scheduleinfo['ScheduleExpression'])
+ print(scheduleinfostr)
+ if "at" in scheduleinfostr:
+ scheduleinfostr=scheduleinfostr[4:23]
+ print(scheduleinfostr)
+ date1 = parser.parse(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
+ date2 = parser.parse(scheduleinfostr)
+ diff = date1 - date2
+ print(diff)
+ print(diff.days)
+ if diff.days > 7:
+ print("schedule is past the scheduled date by 7 seven days and criteria fullfilled to delete")
+ scheduler.delete_schedule(Name=schedule['Name'])
+ sns.publish(TopicArn=mysnstopicarn,Message="scheduler event is deleted")
+
+ return {
+ 'statusCode': 200,
+ 'body': json.dumps('Completed Eventbridge Schedules with past date removed successfully using Lambda!')
+ }
+
+
+
diff --git a/eventbridge-schedule-remove-one-time-schedules-cdk-python/requirements.txt b/eventbridge-schedule-remove-one-time-schedules-cdk-python/requirements.txt
new file mode 100644
index 000000000..a3cc0814c
--- /dev/null
+++ b/eventbridge-schedule-remove-one-time-schedules-cdk-python/requirements.txt
@@ -0,0 +1,3 @@
+aws-cdk-lib==2.70.0
+constructs>=10.0.0,<11.0.0
+boto3==0.0.1
\ No newline at end of file