I am creating boto3 for Cloudwatch rule and I have the following error when i use client.put_targets function.
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutTargets operation: Invalid InputTemplate for target GuardDuty : [Source: (String)"null is in region null"; line: 1, column: 8].
Here is how the code looks like
client.put_targets(Rule='GuardDutyAlarm',
Targets=[{'Id': 'GuardDuty',
'Arn': 'arn:aws:sns:us-west-2:****:GuardDutyAlarmTeams',
'InputTransformer': {
'InputPathsMap': {'severity': '$.detail.severity', 'region': '$.region'},
'InputTemplate': "<severity> is in region <region>"}}])
We had a similar issue and we found how to fix it. You have to do something like that
client.put_targets(Rule='GuardDutyAlarm',
Targets=[{'Id': 'GuardDuty',
'Arn': 'arn:aws:sns:us-west-2:****:GuardDutyAlarmTeams',
'InputTransformer': {
'InputPathsMap': {'severity': '$.detail.severity', 'region': '$.region'},
'InputTemplate': "\" <severity> is in region <region> \"\n" }}])