[{"data":1,"prerenderedAt":68},["ShallowReactive",2],{"pattern-msk-lambda-cdk":3},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":12,"deploy":14,"description":17,"extension":18,"framework":19,"gitHub":20,"highlight":6,"introBox":29,"language":35,"level":36,"meta":37,"patternArch":38,"resources":51,"s3URL":6,"services":60,"stem":61,"testing":62,"videoId":28,"__hash__":67},"patterns\u002Fpatterns\u002Fmsk-lambda-cdk.json","Amazon MSK to AWS Lambda",null,{"headline":8,"text":9},"Cleanup",[10,11],"1. Delete the stack: \u003Ccode>cdk destroy\u003C\u002Fcode>.","2. Confirm the stack has been deleted: \u003Ccode>aws cloudformation list-stacks --query \"StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus\"\u003C\u002Fcode>.",[13],"content\u002Fcontributors\u002Fpablo-silva.json",{"text":15},[16],"npx cdk deploy","Create a Lambda function that subscribes to an MSK topic","json","AWS CDK",{"template":21,"payloads":26},{"projectFolder":22,"repoURL":23,"templateURL":24,"templateFile":25},"msk-lambda-cdk","https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-patterns\u002Ftree\u002Fmain\u002Fmsk-lambda-cdk","serverless-patterns\u002Fmsk-lambda-cdk","lib\u002Fmsk-lambda-cdk-stack.ts",[27],{"headline":28,"payloadURL":28},"",{"headline":30,"text":31},"How it works",[32,33,34],"Lambda is a consumer application for your Kafka topic. It processes records from one or more partitions and sends the payload to the target function. Lambda continues to process batches until there are no more messages in the topic.","Lambda internally polls for new messages from the event source and then synchronously invokes the target Lambda function. Lambda reads the messages in batches and provides these to your function as an event payload. The maximum batch size is configurable. (The default is 100 messages.)","The CDK template creates a Lambda Function that uses a AWSLambdaMSKExecutionRole IAM role to poll a certain topic within a certain MSK Stream as defined as the Event source in the template.","Node.js","100",{},{"icon1":39,"icon2":44,"line1":48},{"x":40,"y":41,"service":42,"label":43},20,50,"msk","Amazon MSK",{"x":45,"y":41,"service":46,"label":47},80,"lambda","AWS Lambda",{"from":49,"to":50,"label":28},"icon1","icon2",{"headline":52,"bullets":53},"Additional resources",[54,57],{"text":55,"link":56},"Using Amazon MSK as an event source for AWS Lambda","https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Fusing-amazon-msk-as-an-event-source-for-aws-lambda\u002F",{"text":58,"link":59},"Using Lambda with Amazon MSK","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fwith-msk.html",{"from":42,"to":46},"patterns\u002Fmsk-lambda-cdk",{"headline":63,"text":64},"Testing",[65,66],"1. Publish messages to the Amazon MSK topic. Follow the steps as outlined in Step 4 to create a client machine and publish messages to the MSK Topic.","2. Retrieve the logs from the Lambda function: \u003Ccode> sam logs -n ENTER_YOUR_CONSUMER_FUNCTION_NAME\u003C\u002Fcode>.","ue5EvejWBtvTE7xCwTF-J2D74ZjJVwXEsCHqaKxNdGg",1780050909995]