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:
- Is it even possible to edit the existing MSK trigger via APIs.
- Or, can new MSK triggers be added and attached via API?
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()
}