RuleTargetInput

class aws_cdk.aws_events.RuleTargetInput

Bases: object

The input to send to the event target.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_appsync as appsync


api = appsync.GraphqlApi(self, "api",
    name="api",
    definition=appsync.Definition.from_file("schema.graphql"),
    authorization_config=appsync.AuthorizationConfig(
        default_authorization=appsync.AuthorizationMode(authorization_type=appsync.AuthorizationType.IAM)
    )
)

rule = events.Rule(self, "Rule",
    schedule=events.Schedule.rate(cdk.Duration.hours(1))
)

rule.add_target(targets.AppSync(api,
    graph_ql_operation="mutation Publish($message: String!){ publish(message: $message) { message } }",
    variables=events.RuleTargetInput.from_object({
        "message": "hello world"
    })
))

Methods

abstractmethod bind(rule)

Return the input properties for this input object.

Parameters:

rule (IRuleRef)

Return type:

RuleTargetInputProperties

Static Methods

classmethod from_event_path(path)

Take the event target input from a path in the event JSON.

Parameters:

path (str)

Return type:

RuleTargetInput

classmethod from_multiline_text(text)

Pass text to the event target, splitting on newlines.

This is only useful when passing to a target that does not take a single argument.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

As with fromText, each line is JSON-encoded, so every line is wrapped in double quotes in the synthesized template. Whether those quotes are visible to the recipient depends on the target service.

Parameters:

text (str)

Return type:

RuleTargetInput

classmethod from_object(obj)

Pass a JSON object to the event target.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

Parameters:

obj (Any)

Return type:

RuleTargetInput

Returns:

RuleTargetInput

classmethod from_text(text)

Pass text to the event target.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

The Rule Target input value will be a single string: the string you pass here. Do not use this method to pass a complex value like a JSON object to a Rule Target. Use RuleTargetInput.fromObject() instead.

The target Input field must be valid JSON, so the text is JSON-encoded when the template is synthesized. As a result a plain string is wrapped in double quotes: fromText('something') renders as Input: '"something"'. The quotes are part of the required JSON encoding, not an extra value added by CDK, and cannot be removed.

Whether those quotes are visible to the recipient depends on the target service. Some targets deliver the JSON-encoded value as-is, so the recipient sees the surrounding quotes (for example, an SNS topic delivering to an email subscriber shows "something"). To send a structured payload, use RuleTargetInput.fromObject() instead.

Parameters:

text (str)

Return type:

RuleTargetInput