question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Argument of type 'Function' is not assignable to parameter of type 'IFunction'.

See original GitHub issue

OS: macOS 10.14.6 aws-cdk/core: 1.0.0 aws-cdk/aws-lambda: 1.0.0 aws-cdk/aws-events: 1.1.0 aws-cdk/aws-events-targets: 1.1.0 cdk: 1.0.0 (build d89592e)

I am trying to create a stack similar to the lambda-cron example.

While adding lambda function to rule, it is erring out.

Add a lambda function as a target: rule.addTarget(new targets.LambdaFunction(queueConsumer));

queueConsumer is a lambda function (aws-cdk/aws-lambda.Function) that consumes messages from a SQS queue.

Error while adding the target Argument of type 'Function' is not assignable to parameter of type 'IFunction'.

Is there any way to get the IFunction object from the lambda.Function object?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:39 (19 by maintainers)

github_iconTop GitHub Comments

20reactions
falnyrcommented, Jan 27, 2021

14reactions
AtomicCactuscommented, Aug 30, 2019

A somewhat dirty workaround that worked for me:

const eventTargets = require("@aws-cdk/aws-events-targets");

const theFunction = new Function(this, ...);

new Rule(this, "Schedule", {
      enabled: true,
      schedule: Schedule.rate(Duration.minutes(15)),
      targets: [new eventTargets.LambdaFunction(theFunction)],
});

Basically using require instead of import solved the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve AWS CDK error "Argument of type 'Function' is ...
This error Argument of type 'SomeClass' is not assignable to parameter of type 'ISomeClass' typically occurs when version of CDK ...
Read more >
awslabs/aws-cdk - Gitter
error TS2345 : Argument of type 'Function' is not assignable to parameter of type 'IFunction'. Function extends FunctionBase which implements IFunction…
Read more >
Argument of type Not Assignable to type Construct in AWS CDK
The reason we get the "Argument of type is not assignable to parameter of type Construct" error in CDK is because we have...
Read more >
AWS CDK - interface IFunction
The principal to grant permissions to. isBoundToVpc. Type: boolean. Whether or not this Lambda function was bound to a VPC. If this ...
Read more >
AWS CDKで”Argument of type 'this' is not assignable to ...
AWS CDKで”Argument of type 'this' is not assignable to parameter of type 'Construct'.”が出た時はpackage.jsonを見ようという話. タイトル落ちですが、覚書です。
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found