Skip to content

bug: Event rule target fails to execute when SF with input transformers #11970

@ianloubser

Description

@ianloubser

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When there is an event rule setup that has a step function configured with target as well as input transformers, it consistently fails to invoke the step function due to a KeyError trying to access id.

Example event rule definition (edited to obfuscate actual properties/names):

FetchCustomerDataEventRule:
  Type: AWS::Events::Rule
  Properties:
    EventBusName:
      Fn::ImportValue: ${env:STAGE}-customer-event-bus
    EventPattern: '{ "detail": { "event": [ "KEY_FOR_EVENT_TYPE" ] } }'
    Name: TriggerTheStepFunction-${opt:stage}
    RoleArn: ${self:provider.role}
    Targets:
      - Arn:
          Ref: SomeStepFunctionArn${opt:stage}
        RoleArn: ${self:provider.role}
        Id: this-is-a-dummy-target
        InputTransformer:
          InputPathsMap:
            customerId: '$.detail.properties.customerId'
          InputTemplate: '{ "customerId": <customerId> }'

Error thrown:

{"ErrorCode": "TargetDeliveryFailure", "ErrorMessage": "Failed to deliver to target this-is-a-dummy-target: 'id'"}

If adding a dummy value for ID in input template it succeeds, ie:

InputTemplate: '{ "id": "dummy_value", "customerId": <customerId> }'

Expected Behavior

Step function execution ID should fallback to a longuid when the input is transformed and original event ID is not available. Should not require mandatory fields in the input template for a target.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker compose up localstack

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

const eventBridge = new EventBridge({ region: env.AWS_REGION, credentials: fromEnv(), logger: console })
...
eventBridge.putEvents({
    Entries: [
      {
        EventBusName: `${STAGE}-customer-event-bus`,
        Source: source,
        DetailType: eventType,
        Detail: JSON.stringify(eventData),
      },
    ],
  });

Environment

- OS: MacOS 14.7.1 (Apple M3 Chip)
- LocalStack:
  LocalStack version: 4.0.3
  LocalStack Docker image sha256:17c2f79ca4e1f804eb912291a19713d4134806325ef0d21d4c1053161dfa72d0
  LocalStack build date:  2024-11-29
  LocalStack build git hash: aa795ed1c

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions