This is an example CDK stack demonstrating how to use AWS EventBridge to invoke a Lambda function on a schedule or using a cron expression. The Lambda function will then write the request ID to a DynamoDB table.
WARNING: By default the EventBridge rule has been configured with a rate of 2 minutes, so you are able to quickly see the result of this example. I would strongly recommend destroying the stack using cdk destroy TheScheduledLambdaStack
so that the scheduled run does not lead to AWS billing you for function invocations.
More information on schedule expressions for AWS EventBridge to change the run frequency of this project can be found here.
dotnet build src
compile this appcdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
- Create an Ubuntu AWS Cloud9 EC2 development environment
- Add the Microsoft repository
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
- Install the .NET Core SDK
sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-3.1
- Clone the CDK Patterns repo
git clone https://github.com/cdk-patterns/serverless.git
- Change directory
cd serverless/the-scalable-webhook/csharp
- Build the project to see if .NET Core has been setup correctly (optional)
dotnet build src
- Deploy the stack
cdk deploy