Skip to content

(aws_events_targets.CloudWatchLogGroup): unable to add aws_events.RuleTargetInput.from_object #19451

@bhsp

Description

@bhsp

What is the problem?

I have an EventBridge rule with an aws.ecs source and detail_type of "ECS Task State Change", which is logged to CloudWatch. This all works fine. I want to transform the event before it's sent to CloudWatch, so our logging platform has some additional attributes. When I set the "event" parameter for the CloudWatchLogGroup target I get a validation error on deploy but not synth . I've used aws_events.RuleTargetInput.from_object() on Lambda targets without issue.

I've omitted the log group creation and its resource policy - as it all works until attempting to utilized "RuleTargetInput.from_object()"

Reproduction Steps

rule = events.Rule(
    self,
    "ecs-task-state-change",
    rule_name="ecs-task-state-change",
    description="ECS Task state change publish to CloudWatch"
    event_pattern=events.EventPattern(
        source=["aws.ecs"],
        detail_type=["ECS Task State Change"]
    ),
    targets=[
        targets.CloudWatchLogGroup(
            log_group,
            event=events.RuleTargetInput.from_object({"SomeParam": "SomeValue"}),
            max_event_age=cdk.Duration.minutes(30),
            retry_attempts=50
        )
    ]
)

What did you expect to happen?

Successful deploy with transformed event data publishing to CloudWatch

What actually happened?

Input and InputPath are not valid forms of input for target Target0. The only valid form of input is InputTransformer. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: 7c2c2338-281f-406b-98e9-6a06ea292af7; Proxy: null)

CDK CLI Version

1.149.0 (build 2bb9d2f)

Framework Version

No response

Node.js Version

v14.17.6

OS

Windows

Language

Python

Language Version

Python (3.8.8)

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions