Unable to add SQS queue as an event source in C#
See original GitHub issueDescribe the bug Adding an SQS queue as an event source to a lambda function throws an exception with message “Parameter count mismatch.” in C#.
To Reproduce
This example adds the queue as an event source after the function object is created, but I receive the same error if I try to add the queue as an event source at the time of function creation via the “Events” property.
Code:
var app = new App(new AppProps());
var stack = new Stack(app, "MyTestStack", new StackProps());
var function = new Function(stack, "MyTestLambdaFunction", new FunctionProps
{
Runtime = Runtime.DotNetCore21,
Handler = "MyTestAssembly::MyTestClass::Handler",
Code = new CfnParametersCode(new CfnParametersCodeProps
{
BucketNameParam = new CfnParameter(stack, "BucketNameParameter", new CfnParameterProps{Type="String"}),
ObjectKeyParam = new CfnParameter(stack, "ObjectKeyParameter", new CfnParameterProps{Type="String"})
}),
FunctionName = "MyTestFunction"
});
var queue = new Queue(stack, "MyTestQueue", new QueueProps
{
QueueName = "MyTestQueue"
});
function.AddEventSource(new SqsEventSource(queue, new SqsEventSourceProps()));
Stacktrace:
An unhandled exception of type 'Amazon.JSII.Runtime.JsiiException' occurred in Amazon.JSII.Runtime.dll: 'Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: System.Reflection.TargetParameterCountException: Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeMethod(InvokeRequest request, IReferenceMap referenceMap)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallback(Callback callback, IReferenceMap referenceMap, IFrameworkToJsiiConverter converter, String& error)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.CDK.AWS.Lambda.EventSources.SqsEventSource.Bind(IIFunction target)'
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.CDK.AWS.Lambda.FunctionBase.AddEventSource(IIEventSource source)
Expected behavior The SQS queue is added as an event source to the lambda function.
Version:
- OSX
- C#
- 0.33
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to add SQS queue as an event source in C# #2692
Adding an SQS queue as an event source to a lambda function throws an exception with message "Parameter count mismatch." in C#. To...
Read more >Tutorial - Use SQS as an Event Source for Lambda
In this tutorial, learn how to use Amazon SQS as an Event Source for Lambda. Lambda allows your code to be triggered using...
Read more >SQS Event Source not being created on AWS SAM Lambda ...
Ref subnetIds Events: BootstrapFunctionSQSEvent: Type: SQS Properties: Queue: !GetAtt TaskQueue.Arn BatchSize: 1 Enabled: true.
Read more >AWS Serverless Failed-Event Destinations - W3Schools
You can do it for both asynchronous and streaming event sources. You can use SNS topic, SQS Queue, or another Lambda function as...
Read more >Why isn't my Lambda function with an Amazon SQS event ...
Your browser can't play this video. ... Why isn't my Lambda function with an Amazon SQS event source scaling optimally?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates on this? It happens on the latest preview as well
Workaround: