本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 Amazon EventBridge 中根据事件 JSON 创建架构
如果您有事件的 JSON,则可以自动为该类型的事件创建架构。
基于事件的 JSON 创建架构
访问 https://console.aws.amazon.com/events/
,打开 Amazon EventBridge 控制台。 -
在导航窗格中,选择架构,然后选择创建架构。
-
(可选)选择或创建架构注册表。
-
在 Schema details (架构详细信息) 下,输入架构的名称。
-
(可选)输入所创建架构的描述。
-
架构类型选择 OpenAPI 3.0。
根据事件的 JSON 创建架构时,不能使用 JSONSchema。
-
选择 Discover from 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 将为该事件生成一个 OpenAPI 架构。例如,以下架构是为上一 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" } } } } } }
-
生成架构后,选择创建。