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.

aws_events.Rule doesn't accept aws_events_targets.SfnStateMachine as a target

See original GitHub issue

When trying to add a target to an event in Python, following error is produced on synth:

Error: Resolution error: Supplied properties not correct for "CfnRuleProps"
  targets: element 0: supplied properties not correct for "TargetProperty"
    arn: required but missing.

Rule is aws_events.Rule object, and target is aws_events_targets.SfnStateMachine.

Reproduction Steps

event = aws_events.Rule(
            self,
            id="Scheduled event",
            enabled=True,
            schedule=aws_events.Schedule.expression(app_config["event_schedule"])
)
event.add_target(aws_events_targets.SfnStateMachine(machine=state_machine))

Error Log

/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/resolvable.js:51
            throw e;
            ^

Error: Resolution error: Supplied properties not correct for "CfnRuleProps"
  targets: element 0: supplied properties not correct for "TargetProperty"
    arn: required but missing.
Object creation stack:
  at new Intrinsic (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/private/intrinsic.js:20:44)
  at new PostResolveToken (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/util.js:72:9)
  at CfnRule._toCloudFormation (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/cfn-resource.js:167:39)
  at elements.map.e (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/stack.js:547:60)
  at Array.map (<anonymous>)
  at Stack._toCloudFormation (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/stack.js:547:36)
  at Stack.synthesize (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/stack.js:500:42)
  at Function.synth (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/construct.js:65:27)
  at App.synth (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/app.js:71:52)
  at process.App.process.once (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/app.js:45:51)
  at Object.onceWrapper (events.js:286:20)
  at process.emit (events.js:198:13)
    at ValidationResult.assertSuccess (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/runtime.js:126:19)
    at cfnRulePropsToCloudFormation (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/aws-events/lib/events.generated.js:165:39)
    at CfnRule.renderProperties (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/aws-events/lib/events.generated.js:214:16)
    at PostResolveToken.ret.Resources.util_1.PostResolveToken.props [as processor] (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/cfn-resource.js:178:52)
    at PostResolveToken.postProcess (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/util.js:80:21)
    at Object.postProcess (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/private/resolve.js:30:82)
    at DefaultTokenResolver.resolveToken (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/resolvable.js:42:38)
    at resolve (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/private/resolve.js:94:33)
    at Object.resolve (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/private/resolve.js:28:33)
    at resolve (/tmp/jsii-kernel-8Mu6hw/node_modules/@aws-cdk/core/lib/private/resolve.js:111:43)

Environment

  • CLI Version : 1.13.1 (build 96cfc63)
  • Framework Version: 1.13.1
  • OS : Fedora
  • Language : Python

Other

This happens in all following cases:

  • By supplying targets keyword in rule constructor
  • By using add_target() on rule object
  • By using bind(rule_obj) on target object

I also checked target type LambdaFunction, but it works (aside from type mismatch, target is based on object instead of implementing IRuleTarget expected by rule object)


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oleksii-donohacommented, Oct 17, 2019

@SomayaB I might be out of the loop, but shouldn’t label “package/events” be more appropriate?

0reactions
raajheshkannaacommented, Oct 14, 2021

The same error happens with having codepipeline as a target for an event as well.

jsii.errors.JavaScriptError: 
  Error: Resolution error: Supplied properties not correct for "CfnRuleProps"
    targets: element 0: supplied properties not correct for "TargetProperty"
      arn: required but missing.

below is the code


		repo = codecommit.Repository(
			self, 'Repository',
			repository_name='Repository'
		)

		source_artifact = codepipeline.Artifact()

		cloud_assembly_artifact = codepipeline.Artifact()

		pipeline = CodePipeline(self, 'Pipeline',
			synth=ShellStep("Synth",
			input=CodePipelineSource.code_commit(
				repository=repo,
				branch='master'),
			commands=[
				'pip install -r requirements', 
				'npm install -g aws-cdk', 
				'cdk synth']
			)
			)

		rule = events.Rule(self, 'TriggerPipeline',
			schedule=events.Schedule.expression('rate(1 hour)')
		)

		rule.add_target(targets.CodePipeline(pipeline))
Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-events-targets module - AWS Documentation
The code snippet below creates an event rule with a Lambda function as a target triggered for every events from aws.ec2 source. You...
Read more >
@aws-cdk/aws-events-targets - npm
The code snippet below creates an event rule with a Lambda function as a target triggered for every events from aws.ec2 source. You...
Read more >
@aws-cdk/aws-events-targets NPM | npm.io
The code snippet below creates an event rule with a Lambda function as a target triggered for every events from aws.ec2 source. You...
Read more >
adding etl workflow to event rule - AWS re:Post
import * as events from "@aws-cdk/aws-events"; const rule = new events. ... I can't find glue workflow as a target on the targets...
Read more >
@aws-cdk/aws-events-targets | Yarn - Package Manager
... classes to send Amazon EventBridge to any number of supported AWS Services. Instances of these classes should be passed to the rule.addTarget()...
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