Category : lambda

I am trying to read values from a kafka topic (AWS MSK) using AWS lambda. The event record when printed from lambda looks like this: {‘eventSource’: ‘aws:kafka’, ‘eventSourceArn’: ‘arn:aws:kafka:ap-northeast-1:987654321:cluster/mskcluster/79y80c66-813a-4f-af0e-4ea47ba107e6’, ‘records’: {‘Transactions-0’: [{‘topic’: ‘Transactions’, ‘partition’: 0, ‘offset’: 4798, ‘timestamp’: 1603565835915, ‘timestampType’: ‘CREATE_TIME’, ‘value’: ‘eyJFdmVudFRpbWUiOiAiMjAyMC0xMC0yNCAxODo1NzoxNS45MTUzMjQiLCAiSVAiOiAiMTgwLjI0MS4xNTkuMjE4IiwgIkFjY291bnROdW1iZXIiOiwiMTQ2ODA4ODYiLCAiVXNlck5hbWUiOi67iQW1iZXIgUm9tYXJvIiwgIkFtb3VudCI6ICI1NTYyIiwgIlRyYW5zYWN0aW9uSUQiOiAiTzI4Qlg3TlBJbWZmSXExWCIsICJDb3VuTHJ5IjogIk9tYW4ifQ==’}]}} How can I extract the ‘topic’ and ‘value’ fields? The value one ..

Read more

I am trying to store lambda functions in a python dictionary. It seems that the loop overwrites all of the data stored in the dictionary with the last lambda. For example: example_dict = {} for i in range(5): example_dict[i] = lambda x: x + i for key, func in example_dict.items(): print(key, func(10)) Should output 0 ..

Read more

I currently have my lambda handler set up using FastAPI middleware decorator and Mangum like the following: from routers import router app = FastAPI() app.include_router(router) # Handler for api calls @app.middleware("http") async def api_process(request: Request, call_next): try: if path in endpoints_list: # … validation logics here … response = await call_next(request) # calls the endpoints ..

Read more