I am trying to update the existing MSK trigger my lambda function by adding topics to the list via API. If Editing is not possible I am also open to creating a new MSK trigger.
This new trigger will be added to the existing lambda via another lambda function that would have its own events.
Can someone guide me:
Tried digging the documentations: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.update_function_event_invoke_config https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#putFunctionEventInvokeConfig-property
Code:
var AWS = require('aws-sdk');
var config = require('./config')
var lambda = new AWS.Lambda({region: config.AWS_REGION});
const listEventSource = async () => {
var params = {
FunctionName: config.LAMBDA_FUNCTION_NAME
};
res = await lambda.listEventSourceMappings(params).promise()
console.log(res)
};
const createMSKTrigger = async ()=>{
var params = {
FunctionName: config.LAMBDA_FUNCTION_NAME,
BatchSize: 'NUMBER_VALUE',
BisectBatchOnFunctionError: true || false,
DestinationConfig: {
OnFailure: {
Destination: 'STRING_VALUE'
},
OnSuccess: {
Destination: 'STRING_VALUE'
}
},
Enabled: true || false,
EventSourceArn: 'STRING_VALUE',
FunctionResponseTypes: [
ReportBatchItemFailures,
/* more items */
],
MaximumBatchingWindowInSeconds: 'NUMBER_VALUE',
MaximumRecordAgeInSeconds: 'NUMBER_VALUE',
MaximumRetryAttempts: 'NUMBER_VALUE',
ParallelizationFactor: 'NUMBER_VALUE',
Queues: [
'STRING_VALUE',
/* more items */
],
SelfManagedEventSource: {
Endpoints: {
'<EndPointType>': [
'STRING_VALUE',
/* more items */
],
/* '<EndPointType>': ... */
}
},
SourceAccessConfigurations: [
{
Type: BASIC_AUTH | VPC_SUBNET | VPC_SECURITY_GROUP | SASL_SCRAM_512_AUTH | SASL_SCRAM_256_AUTH,
URI: 'STRING_VALUE'
},
/* more items */
],
StartingPosition: TRIM_HORIZON | LATEST | AT_TIMESTAMP,
StartingPositionTimestamp: new Date || 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)' || 123456789,
Topics: [
'STRING_VALUE',
/* more items */
],
TumblingWindowInSeconds: 'NUMBER_VALUE'
};
triggerRes = lambda.createEventSourceMapping(params).promise()
}
Python - Boto3
You can update the trigger using update_event_source mapping method.
You can create the trigger using create_event_source mapping method.
Javascript - AWS SDK
You can update the trigger using UpdateEventSourceMappingCommand class.
You can create the trigger using CreateEventSourceMappingCommand class.
Below are the AWS documentation "Using Lambda with Amazon MSK". https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html
I hope this can help you with your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.