Tutorial: Creating a REST API ConnectionType and Connection
Connecting to the Foo REST API
We will create an Amazon Glue REST API ConnectionType and a corresponding Amazon Glue connection for the Foo REST API. This API has the following properties (which can be retrieved from REST API documentation).
-
Instance URL: https://foo.cloud.com/rest/v1.
-
Authentication type: OAuth2 (Client Credentials).
-
REST method: GET.
-
Pagination type: Offset with properties “limit” and “offset” placed in query parameter of request.
-
Supported entities:
-
Bar: relative path [/bar.json].
-
Baz: relative path [/baz.json].
-
Once all the details are obtained, we can begin creating the Amazon Glue connection to the Foo REST API.
To create a REST API connection:
-
Create the REST API connection type in Amazon Glue by calling the RegisterConnectionType API using Amazon API, CLI, or SDK. This will create a new ConnectionType resource in Amazon 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" } } } } } } -
In Amazon Secrets Manager, create a secret. The Secret should contain the connected app Consumer Secret with
USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRETas key.Note
You must create a secret per connection in Amazon Glue
-
Create the Amazon Glue connection by calling the CreateConnection API using the Amazon API, CLI, or SDK.
-
Reference the REST connection type name from Step 1 as the “ConnectionType”.
-
Provide the InstanceUrl and any other ConnectionProperties that were defined during the Amazon Glue ConnectionType registration process.
-
Choose from the configured Authentication Types. The REST API Foo uses OAuth2 with the ClientCredentials grant type.
-
Provide the SecretArn and other AuthenticationProperties that are configured. For example, we have configured
OAUTH2as the AuthenticationType so we will set the “OAuth2Properties” in the CreateConnectionInput. This will require properties like “OAuth2GrantType”, “TokenUrl”, and “OAuth2ClientApplication”.
-
-
Make the CreateConnection request which will create the Amazon Glue connection.
{ "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" } } } } }