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 Answer
1
Accepted Answer

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
EXPERT
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions