Skip to content

events.EventBridgeEvent is returning an empty payload when called by the EventBridge Scheduler #563

Open
@ryanparsa

Description

@ryanparsa

Hi guys,

I'm trying to invoke a Lambda function using EventBridge Scheduler, but I'm not receiving the JSON payload in the Lambda.

Here are the details:

Scheduler:

{
    "ActionAfterCompletion": "NONE",
    "Arn": "arn:aws:scheduler:us-east-1:?:schedule/default/backup1",
    "CreationDate": "2024-05-16T19:44:38.262000-07:00",
    "Description": "",
    "FlexibleTimeWindow": {
        "Mode": "OFF"
    },
    "GroupName": "default",
    "LastModificationDate": "2024-05-16T20:07:32.388000-07:00",
    "Name": "backup1",
    "ScheduleExpression": "cron(* * ? * * 2024)",
    "ScheduleExpressionTimezone": "America/?",
    "State": "ENABLED",
    "Target": {
        "Arn": "arn:aws:lambda:us-east-1:?:function:backup",
        "Input": "{\"backupID\": \"123\", \"key2\": \"value2\", \"key3\": \"value3\"}",
        "RetryPolicy": {
            "MaximumEventAgeInSeconds": 86400,
            "MaximumRetryAttempts": 0
        },
        "RoleArn": "arn:aws:iam::?:role/service-role/Amazon_EventBridge_Scheduler_LAMBDA"
    }
}

lambda:

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/config"
	"log"
)



func LambdaHandler(ctx context.Context, event events.EventBridgeEvent) (*string, error) {
	fmt.Println("LambdaHandler")
	fmt.Printf("ctx: %#v\n", ctx)
	fmt.Printf("event: %#v\n", event)

	message := fmt.Sprintf("Hello %s!", "lambda")
	return &message, nil
}

func main() {
	lambda.Start(LambdaHandler)
}

cloud watch:


2024/05/17 04:17:20 im LambdaHandler
ctx: context.Background.WithDeadline(2024-05-17 04:17:23.103 +0000 UTC [2.999198593s]).WithValue(type *lambdacontext.key, val <not Stringer>).WithValue(type string, val Root=1-6646da50-1;Parent=1;Sampled=0;Lineage=a8ed5ba3:0)

event: {Version: ID: DetailType: Source: AccountID: Time:0001-01-01 00:00:00 +0000 UTC Region: Resources:[] Detail:[]}



go.mod

module backup

go 1.22.0

require (
	github.com/aws/aws-lambda-go v1.47.0 // indirect
	github.com/aws/aws-sdk-go-v2 v1.27.0 // indirect
	github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
	github.com/aws/aws-sdk-go-v2/config v1.27.15 // indirect
	github.com/aws/aws-sdk-go-v2/credentials v1.17.15 // indirect
	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 // indirect
	github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 // indirect
	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.7 // indirect
	github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
	github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.7 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.7 // indirect
	github.com/aws/aws-sdk-go-v2/service/s3 v1.54.2 // indirect
	github.com/aws/aws-sdk-go-v2/service/sso v1.20.8 // indirect
	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2 // indirect
	github.com/aws/aws-sdk-go-v2/service/sts v1.28.9 // indirect
	github.com/aws/smithy-go v1.20.2 // indirect
)

It appears that the events.EventBridgeEvent object in the Lambda function is empty. Any ideas on what might be causing this or how to fix it?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions