Skip to content

aws-events-targets: RuleTargetInput.from_text adds double quotes to message #38121

Description

@TomasChmelik

Describe the bug

I'm sending message to SNS topic from EventBridge rule and configure the message.

When I use either aws_events.RuleTargetInput.from_text the resulting message is wrapped in double quotes (if I would use aws_events.RuleTargetInput.from_multiline_text, each line is wrapped with double quotes) without any way (at least obvious one for me) how to avoid that.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

aws_events.RuleTargetInput.from_text('something') would result into something to be the final message.

Resources:
  Rule:
    Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - ...
      Name: rule
      State: ENABLED
      Targets:
        - Arn:
            Ref: Topic
          Id: Target0
          Input: something

Current Behavior

aws_events.RuleTargetInput.from_text('something') actually results into "something".

Resources:
  Rule:
    Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - ...
      Name: rule
      State: ENABLED
      Targets:
        - Arn:
            Ref: Topic
          Id: Target0
          Input: '"something"'

Reproduction Steps

from aws_cdk import aws_events, aws_events_targets, aws_sns

aws_events.Rule(
    self,
    'Rule',
    enabled=True,
    rule_name='rule',
    event_pattern=aws_events.EventPattern(source=['...']),
    targets=[
        aws_events_targets.SnsTopic(
            topic,
            message=aws_events.RuleTargetInput.from_text('something')
        )
    ]
)

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.257.0

AWS CDK CLI version

2.1125.0

Node.js Version

v22.9.0

OS

Ubuntu 20

Language

Python

Language Version

Python 3.14.2

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions