本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
JSON在 Amazon 中從事件創建模式 EventBridge
如果您有事件JSON的,您可以自動為該類型的事件建立結構描述。
若要根據事件JSON的建立結構描述
在打開 Amazon EventBridge 控制台https://console.aws.amazon.com/events/
。 -
在導覽窗格中,選擇結構描述,然後選擇建立結構描述。
-
(選用) 選取或建立結構描述登錄檔。
-
在結構描述詳細資訊下,輸入結構描述的名稱。
-
(選用) 為您建立的結構描述輸入描述。
-
針對結構描述類型,選擇「開啟 API 3.0」。
JSONSchema當您從事件JSON的建立結構描述時,您無法使用。
-
選擇「探索自」JSON
-
在下方的文字方塊中 JSON,貼上或拖曳事件JSON來源。
例如,您可以貼上來自此 AWS Step Functions 事件的來源,以便執行失敗。
{ "version": "0", "id": "315c1398-40ff-a850-213b-158f73e60175", "detail-type": "Step Functions Execution Status Change", "source": "aws.states", "account": "012345678912", "time": "2019-02-26T19:42:21Z", "region": "us-east-1", "resources": [ "arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name" ], "detail": { "executionArn": "arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name", "stateMachineArn": "arn:aws:states:us-east-1:012345678912:stateMachine:state-machine", "name": "execution-name", "status": "FAILED", "startDate": 1551225146847, "stopDate": 1551225151881, "input": "{}", "output": null } }
-
選擇探索結構描述。
-
EventBridge 會產生事件的 Open API 結構描述。例如,會針對先前的 Step Functions 事件產生下列結構描述。
{ "openapi": "3.0.0", "info": { "version": "1.0.0", "title": "StepFunctionsExecutionStatusChange" }, "paths": {}, "components": { "schemas": { "AWSEvent": { "type": "object", "required": ["detail-type", "resources", "detail", "id", "source", "time", "region", "version", "account"], "x-amazon-events-detail-type": "Step Functions Execution Status Change", "x-amazon-events-source": "aws.states", "properties": { "detail": { "$ref": "#/components/schemas/StepFunctionsExecutionStatusChange" }, "account": { "type": "string" }, "detail-type": { "type": "string" }, "id": { "type": "string" }, "region": { "type": "string" }, "resources": { "type": "array", "items": { "type": "string" } }, "source": { "type": "string" }, "time": { "type": "string", "format": "date-time" }, "version": { "type": "string" } } }, "StepFunctionsExecutionStatusChange": { "type": "object", "required": ["output", "input", "executionArn", "name", "stateMachineArn", "startDate", "stopDate", "status"], "properties": { "executionArn": { "type": "string" }, "input": { "type": "string" }, "name": { "type": "string" }, "output": {}, "startDate": { "type": "integer", "format": "int64" }, "stateMachineArn": { "type": "string" }, "status": { "type": "string" }, "stopDate": { "type": "integer", "format": "int64" } } } } } }
-
產生結構描述之後,請選擇建立。