AWS EventBridge discards request headers and parameters for scheduled API Destinations calls using Localstack

Viewed 419

I am using Localstack in local environment to schedule cron calls every minute to a dummy POST endpoint (using https://webhook.site/) which works fine. However, only the body is kept (from put-targets, not from create-connection) but the request headers, query string parameters and path parameters are all discarded. Whether I test this with AWS CLI or with a Golang example (just to confirm the issue), the issue still persist. Just wondering if anyone has come across with such issue before or am I missing something? As the documentation states we could set these info on both Connection and Targets which I did just in case with both.

Localstack

version: "2.1"

services:
  localstack:
    image: "localstack/localstack"
    container_name: "localstack"
    ports:
      - "4566-4599:4566-4599"
    environment:
      - DEBUG=1
      - DEFAULT_REGION=eu-west-1
      - SERVICES=events
      - DATA_DIR=/tmp/localstack/data
      - DOCKER_HOST=unix:///var/run/docker.sock
      - LAMBDA_EXECUTOR=docker
    volumes:
      - "/tmp/localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

CLI example

Create rule

aws --profile localstack --endpoint-url http://localhost:4566 events put-rule \
    --name http-api-cron-rule \
    --schedule-expression "cron(* * * * *)"

{
    "RuleArn": "arn:aws:events:eu-west-1:000000000000:rule/http-api-cron-rule"
}

Create connection

aws --profile localstack --endpoint-url http://localhost:4566 events create-connection \
    --name http-api-connection \
    --authorization-type Basic \
    --auth-parameters "{\"BasicAuthParameters\":{\"Username\":\"hello\",\"Password\":\"world\"},\"InvocationHttpParameters\":{\"HeaderParameters\":[{\"Key\":\"hdr\",\"Value\":\"val\",\"IsValueSecret\":false}],\"QueryStringParameters\":[{\"Key\":\"qry\",\"Value\":\"val\",\"IsValueSecret\":false}],\"BodyParameters\":[{\"Key\":\"bdy\",\"Value\":\"val\",\"IsValueSecret\":false}]}}"

{
    "ConnectionArn": "arn:aws:events:eu-west-1:000000000000:connection/http-api-connection/4c6a29cf-4665-41f1-b90f-a43e41712e5e",
    "ConnectionState": "AUTHORIZED",
    "CreationTime": "2022-01-07T17:24:57.854127+00:00",
    "LastModifiedTime": "2022-01-07T17:24:57.854127+00:00"
}

Create destination Obtain a URL from https://webhook.site first and use below.

aws --profile localstack --endpoint-url http://localhost:4566 events create-api-destination \
    --name http-api-destination \
    --connection-arn "arn:aws:events:eu-west-1:000000000000:connection/http-api-connection/4c6a29cf-4665-41f1-b90f-a43e41712e5e" \
    --http-method POST \
    --invocation-endpoint "https://webhook.site/PUT-YOUR-OWN-UUID-HERE"

{
    "ApiDestinationArn": "arn:aws:events:eu-west-1:000000000000:api-destination/http-api-destination/c582470b-4413-4dba-bde9-e7d1aef64ac9",
    "ApiDestinationState": "ACTIVE",
    "CreationTime": "2022-01-07T17:27:27.608361+00:00",
    "LastModifiedTime": "2022-01-07T17:27:27.608361+00:00"
}

Create target

aws --profile localstack --endpoint-url http://localhost:4566 events put-targets \
    --rule http-api-cron-rule \
    --targets '[{"Id":"1","Arn":"arn:aws:events:eu-west-1:000000000000:api-destination/http-api-destination/c582470b-4413-4dba-bde9-e7d1aef64ac9","Input":"{\"bdyx\":\"val\"}","HttpParameters":{"PathParameterValues":["parx"],"HeaderParameters":{"hdrx":"val"},"QueryStringParameters":{"qryx":"val"}}}]'

{
    "Targets": [
        {
            "Id": "1",
            "Arn": "arn:aws:events:eu-west-1:000000000000:api-destination/http-api-destination/c582470b-4413-4dba-bde9-e7d1aef64ac9",
            "Input": "{\"bdyx\":\"val\"}",
            "HttpParameters": {
                "PathParameterValues": [
                    "parx"
                ],
                "HeaderParameters": {
                    "hdrx": "val"
                },
                "QueryStringParameters": {
                    "qryx": "val"
                }
            }
        }
    ]
}

Logs

localstack    | DEBUG:localstack.services.events.events_listener: Notifying 1 targets in response to triggered Events rule http-cron-rule
localstack    | DEBUG:localstack.utils.aws.message_forwarding: Calling EventBridge API destination (state "ACTIVE"): POST https://webhook.site/your-uuid-goes-here
0 Answers
Related