本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
教學課程:建立 REST API ConnectionType 和 Connection
連線至 Foo REST API
我們將為 Foo AWS Glue REST API 建立 REST API ConnectionType 和對應的 AWS Glue 連線。此 API 具有下列屬性 (可從 REST API 文件擷取)。
-
執行個體 URL:https://https://foo.cloud.com/rest/v1。
-
身分驗證類型:OAuth2 (用戶端登入資料)。
-
REST 方法:GET。
-
分頁類型:在請求的查詢參數中放置屬性 "limit" 和 "offset" 的位移。
-
支援的實體:
-
長條:相對路徑 【/bar.json】。
-
Baz:相對路徑 【/baz.json】。
-
取得所有詳細資訊後,我們可以開始建立與 Foo REST API 的 AWS Glue 連線。
若要建立 REST API 連線:
-
使用 API、CLI 或 SDK 呼叫 RegisterConnectionType API, AWS Glue 在 中建立 REST AWS API 連線類型。這將在 中建立新的 ConnectionType 資源 AWS Glue。
{ "ConnectionType": "REST-FOO-CONNECTOR", "IntegrationType": "REST", "Description": "AWS Glue Connection Type for the FOO REST API", "ConnectionProperties": { "Url": { "Name": "Url", "Required": true, "DefaultValue": "https://foo.cloud.com/rest/v1", "PropertyType": "USER_INPUT" } }, "ConnectorAuthenticationConfiguration": { "AuthenticationTypes": ["OAUTH2"], "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS" } }, "RestConfiguration": { "GlobalSourceConfiguration": { "RequestMethod": "GET", "ResponseConfiguration": { "ResultPath": "$.result", "ErrorPath": "$.error.message" }, "PaginationConfiguration": { "OffsetConfiguration": { "OffsetParameter": { "Key": "offset", "PropertyLocation": "QUERY_PARAM" }, "LimitParameter": { "Key": "limit", "PropertyLocation": "QUERY_PARAM", "DefaultValue": "50" } } } }, "ValidationEndpointConfiguration": { "RequestMethod": "GET", "RequestPath": "/bar.json?offset=1&limit=10" }, "EntityConfigurations": { "bar": { "SourceConfiguration": { "RequestMethod": "GET", "RequestPath": "/bar.json", "ResponseConfiguration": { "ResultPath": "$.result", "ErrorPath": "$.error.message" } }, "Schema": { "name": { "Name": "name", "FieldDataType": "STRING" }, "description": { "Name": "description", "FieldDataType": "STRING" }, "id": { "Name": "id", "FieldDataType": "STRING" }, "status": { "Name": "status", "FieldDataType": "STRING" } } } } } } -
在 AWS Secrets Manager 中建立秘密。秘密應該包含以
USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRET做為金鑰的已連線應用程式消費者秘密。注意
您必須在 中為每個連線建立秘密 AWS Glue
-
使用 API、CLI 或 SDK 呼叫 CreateConnection AWS API 來建立 AWS Glue 連線。
-
參考步驟 1 中的 REST 連線類型名稱做為「ConnectionType」。
-
提供 InstanceUrl 和在 ConnectionType 註冊程序期間定義的任何其他 ConnectionProperties。 AWS Glue ConnectionType
-
從設定的身分驗證類型中選擇。REST API Foo 使用 OAuth2 搭配 ClientCredentials 授予類型。
-
提供已設定的 SecretArn 和其他 AuthenticationProperties。例如,我們已將
OAUTH2設定為 AuthenticationType,因此我們會在 CreateConnectionInput 中設定「OAuth2Properties」。這將需要屬性,例如「OAuth2GrantType」、「TokenUrl」和「OAuth2ClientApplication」。
-
-
提出 CreateConnection 請求以建立 AWS Glue 連線。
{ "ConnectionInput": { "Name": "ConnectionFooREST", "ConnectionType": "REST-FOO-CONNECTOR", "ConnectionProperties": {}, "ValidateCredentials": true, "AuthenticationConfiguration": { "AuthenticationType": "OAUTH2", "SecretArn": "arn:aws:secretsmanager:<region>:<accountId>:secret:<secretId>", "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS", "TokenUrl": "https://foo.cloud.com/oauth/token", "OAuth2ClientApplication": { "UserManagedClientApplicationClientId": "your-managed-client-id" } } } } }