在將輸入添加到我的事件目標時,我在使用 AWS CLI 時遇到了一些問題。沒有輸入這個命令和 json 檔案作業正常。通過控制臺創建輸入時,我沒有任何問題。
BASH 命令:
aws events put-targets --cli-input-json file://target.json
JSON 檔案:
{
"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"
}
]
}
錯誤資訊:
呼叫 PutTargets 操作時發生錯誤 (ValidationException):目標 site.la-01 的輸入中的 JSON 語法錯誤:[來源:(字串)“這是一個輸入”;行:1,列:5
其他資訊:
- JSON 檔案的編碼為 us-ascii
- 我正在關注此處的檔案:https : //awscli.amazonaws.com/v2/documentation/api/2.1.29/reference/events/put-targets.html
謝謝您的幫助!
uj5u.com熱心網友回復:
輸入欄位應為 json 格式。
輸入 ->(字串)
傳遞給目標的有效 JSON 文本。在這種情況下,事件本身沒有任何內容傳遞給目標。
所以 target.json 應該是這樣的:
{
"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\"}"
}
]
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/403334.html
標籤:
