Invalid InputTemplate for target

0

I have set up CloudWatch rule that triggerent scheduled event to Lambda. I wanted to add custom information to lambda using details in ScheduledEvent. Using new Input Transformer feature to craft input based on JSON event data, but getting below issue

Invalid InputTemplate for target Target0 : [Source: (String)"{ "version": null, "id": null, "source": null, "account": null, "time": null, "region": null, "resources": null, "detail": [{ "StartDate": "2023/07/07", "EndDate": "2023/07/09" }], "detail-type": null, } "; line: 15, column: 2].

Sample Event: { "version": "0", "id": "89d1a02d-5ec7-412e-82f5-13505f849b41", "detail-type": "Scheduled Event", "source": "aws.events", "account": "123456789012", "time": "2016-12-30T18:44:49Z", "region": "us-east-1", "resources": ["arn:aws:events:us-east-1:123456789012:rule/SampleRule"], "detail": {} }

input Path { "version": "$.version", "id": "$.id", "source": "$.source", "account": "$.account", "time": "$.time", "region": "$.region", "resources": "$.resources", "detail-type": "$.detail-type" }

Template { "version": <version>, "id": <id>, "source": <source>, "account": <account>, "time": <time>, "region": <region>, "resources": <resources>, "detail": [{ "StartDate": "2023/07/07", "EndDate": "2023/07/09"

}], "detail-type": <detail-type>, }

Output { "version": 0, "id": 89d1a02d-5ec7-412e-82f5-13505f849b41, "source": aws.events, "account": 123456789012, "time": 2016-12-30T18:44:49Z, "region": us-east-1, "resources": arn:aws:events:us-east-1:123456789012:rule/SampleRule, "detail": [{ "StartDate": "2023/07/07", "EndDate": "2023/07/09"

}], "detail-type": Scheduled Event, }

1 Antwort
1
Akzeptierte Antwort

Try the following input template.
The problem was that the ""detail-type": <detail-type>" had a "," at the end.

{ 
    "version": <version>,
    "id": <id>,
    "source": <source>,
    "account": <account>,
    "time": <time>,
    "region": <region>,
    "resources": <resources>,
    "detail": [
        {
            "StartDate": "2023/07/07",
            "EndDate": "2023/07/09"
        }
    ],
    "detail-type": <detail-type>
}
profile picture
EXPERTE
beantwortet vor 10 Monaten
profile picture
EXPERTE
überprüft vor 10 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen