AWS CLI: aws events put-targets --cli-input-json file://target.json giving JSON syntax error

2.5k views Asked by At

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:

Thank you for your help!

1

There are 1 answers

1
OARP On BEST ANSWER

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\"}"
        }
    ]
}