CREATE LINK
Create a new connection link to S3, Azure, GCS, HDFS, HTTP, or Kafka for a permitted user.
Syntax
CREATE LINK [db_name.]connection_name AS { S3 | AZURE | GCS | HDFS | HTTP | KAFKA } CREDENTIALS 'credentials_json' [ CONFIG 'configuration_json' ] [ DESCRIPTION 'description' ]
Remarks
db_name
is the name of the SingleStoreDB database. It is an optional parameter. If not specified, the connection link is created in the current (context) database.CONFIG
andCREDENTIALS
can be specified in either order (CONFIG
followed byCREDENTIALS
orCREDENTIALS
followed byCONFIG
).The
CONFIG
andCREDENTIALS
expect json formatted information. See the examples below. For more configuration examples refer BACKUP DATABASEconnection_name
is a user defined name of the connection link.Only users with
CREATE LINK
permission can create a connection link.description
specifies the details related to the connection link.Commands such as
BACKUP
,RESTORE
,CREATE PIPELINE
, andSELECT
support connection links. Refer to any of these commands for details on thecredentials_json
andconfiguration_json
clauses.This command causes implicit commits. See COMMIT for more information.
This command can be used to create regular and encrypted HTTP links. Refer to Using HTTP connection links for more information and examples.
See the Permission Matrix for the required permission.
Examples
AWS S3 Example
The configuration_json
and credentials_json
for AWS connections look like this:
CREDENTIALS '{ "aws_access_key_id": "replace_with_your_access_key_id", "aws_secret_access_key": "replace_with_your_secret_access_key" [, "aws_session_token": "replace_with_your_temp_session_token"] [, "role_arn":"replace_with_your_role_arn"] }' CONFIG: ‘{ "region": "your_region", "endpoint_url": "http://other_endpoint" [,"x-amz-server-side-encryption":"<encryption_type>" [, "x-amz-server-side-encryption-aws-kms-key-id":"<optional_key>" ] | "x-amz-server-side-encryption-customer-algorithm":"<encryption_type>", "x-amz-server-side-encryption-customer-key":"<encrypted_or_unencrypted_key>", "x-amz-server-side-encryption-customer-key-MD5":"<key>" ] }'
For other options for the CONFIG clause (disable_gunzip
, request_payer
, and others) see S3 Pipeline Syntax.
The following example demonstrates how to create an S3 connection link product_S3
to the database Orderdb
.
CREATE LINK Orderdb.product_S3 AS S3 CREDENTIALS '{"aws_access_key_id":"your_access_key_id", "aws_secret_access_key":"your_secret_access_key"}' CONFIG '{"region":"us-east-1"}' DESCRIPTION 'Products ordered in December';
Azure Example
The credentials_json
for Azure looks like this:
CREDENTIALS '{ "account_name": "your_account_name", "account_key": "encrypted_key" }';
CONFIG parameters for Azure links are ignored.
The following example shows how to create an Azure connection link.
CREATE LINK [db_name.]connection_name AS AZURE CREDENTIALS '{ "account_name": "your_account", "account_key": "encrypted_key" }';
GCS Example
The credentials_json
for GCS looks like this:
CREDENTIALS '{ "access_id": "your_google_access_key", "secret_key": "your_google_secret_key" };
The following example demonstrates how to create a GCS connection link called mylink
.
CREATE LINK mylink AS GCS 'mybucket/subdir' CREDENTIALS '{ "access_id": "your_google_access_key", "secret_key": "your_google_secret_key" }';
For more information about GCS credentials, see Authentication and Access Control in GCS.
HTTP Example
The following example demonstrates how to create an HTTP link.
CREATE LINK test AS HTTP CREDENTIALS '{"headers": {"Authorization": "Basic cm9vdDp0ZXN0aW5nCg=="}}';
Refer to Using HTTP connection links for more information and examples.
Kafka Example
The credentials_json
and config_json
for Kafka can be complex. See Kafka Pipeline Syntax for more information.
The following example demonstrates how to create a Kafka connection link for Confluent Cloud.
CREATE LINK mylink AS KAFKA CONFIG '{ "security.protocol": "sasl_ssl", "sasl.mechanism": "PLAIN" }' CREDENTIALS '{ "sasl.username": "your_sasl_username", "sasl.password": "your_sasl_secret_key" }';