チュートリアル: REST API ConnectionType と Connection の作成
Foo REST API への接続
Foo REST API AWS Glue の REST API ConnectionType と対応するAWS Glue接続を作成します。この API には次のプロパティがあります (REST API ドキュメントから取得できます)。
-
インスタンス URL: https://foo.cloud.com/rest/v1。
-
認証タイプ: OAuth2 (クライアント認証情報)。
-
REST メソッド: GET。
-
ページ分割タイプ: リクエストのクエリパラメータに配置されたプロパティ「制限」と「オフセット」を使用したオフセット。
-
サポートされているエンティティ:
-
Bar: 相対パス [/bar.json]。
-
Baz: 相対パス [/baz.json]。
-
すべての詳細を取得したら、Foo REST API への AWS Glue 接続の作成を開始できます。
REST API 接続を作成するには:
-
AWS API、CLI、または SDK を使用して RegisterConnectionType API を呼び出し、AWS Glue で REST API 接続タイプを作成します。これにより、AWS Glue に新しい ConnectionType リソースが作成されます。
{ "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 で接続ごとにシークレットを作成する必要があります
-
AWS API、CLI、または SDK を使用して CreateConnection API を呼び出して AWS Glue 接続を作成します。
-
ステップ 1 の REST 接続タイプ名を「ConnectionType」として参照します。
-
AWS Glue ConnectionType 登録プロセス中に定義された InstanceUrl およびその他の ConnectionProperties を指定します。
-
設定された認証タイプから選択します。REST API Foo は ClientCredentials 許可タイプで OAuth2 を使用します。
-
SecretArn と設定されている他の AuthenticationProperties を指定します。例えば、AuthenticationType として
OAUTH2を設定しているため、CreateConnectionInput で「OAuth2Properties」を設定します。これには、「OAuth2GrantType」、「TokenUrl」、「OAuth2ClientApplication」などのプロパティが必要です。
-
-
AWS Glue 接続を作成する CreateConnection リクエストを作成します。
{ "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" } } } } }