I am having some trouble working with the AWS CLI when including an input to my event target. Without the input this command and json file work fine. When creating inputs via the console I don't have any problems.
BASH command:
aws events put-targets --cli-input-json file://target.json
JSON File:
{
"Rule": "site.la-01-rule",
"Targets": [
{
"Id": "site.la-01",
"Arn": "arn:aws:lambda:us-west-1:<account-number>:function:annual-rotation-schedules",
"Input": "This is an input"
}
]
}
ERROR Message:
An error occurred (ValidationException) when calling the PutTargets operation: JSON syntax error in input for target site.la-01: [Source: (String)"This is an input"; line: 1, column: 5
OTHER INFO:
- The encoding of the JSON file is us-ascii
- I am following the documentation here: https://awscli.amazonaws.com/v2/documentation/api/2.1.29/reference/events/put-targets.html
Thank you for your help!
CodePudding user response:
The Input field should be in json format.
Input -> (string)
Valid JSON text passed to the target. In this case, nothing from the event itself is passed to the target.
So the target.json should be something like:
{
"Rule": "site.la-01-rule",
"Targets": [{
"Id": "site.la-01",
"Arn": "arn:aws:lambda:us-west-1:<account-number>:function:annual-rotation-schedules",
"Input": "{\"key\":\"value\"}"
}
]
}
