Skip to content

Commit 0cef64b

Browse files
authored
Update create-connection.md
1 parent 90a62fe commit 0cef64b

File tree

1 file changed

+66
-3
lines changed

1 file changed

+66
-3
lines changed

docs/en/sql-reference/10-sql-commands/00-ddl/13-connection/create-connection.md

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,64 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
88

99
Creates a connection to external storage.
1010

11+
:::warning
12+
IMPORTANT: When objects (stages, tables, etc.) use a connection, they copy and store the connection's parameters permanently. If you later modify the connection using CREATE OR REPLACE CONNECTION, existing objects will continue using the old parameters. To update objects with new connection parameters, you must drop and recreate those objects.
13+
:::
14+
1115
## Syntax
1216

1317
```sql
1418
CREATE [ OR REPLACE ] CONNECTION [ IF NOT EXISTS ] <connection_name>
1519
STORAGE_TYPE = '<type>'
1620
[ <storage_params> ]
17-
1821
```
1922

2023
| Parameter | Description |
2124
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
2225
| STORAGE_TYPE | Type of storage service. Possible values include: `s3`, `azblob`, `gcs`, `oss`, and `cos`. |
23-
| storage_params | Vary based on storage type and authentication method. See [Connection Parameters](../../../00-sql-reference/51-connect-parameters.md) for details. |
26+
| storage_params | Vary based on storage type and authentication method. See details below for common authentication methods. |
27+
28+
For other storage types and additional parameters, see [Connection Parameters](../../../00-sql-reference/51-connect-parameters.md) for details.
29+
30+
### Authentication Methods for Amazon S3
31+
32+
Databend supports two primary authentication methods for Amazon S3 connections:
33+
34+
#### 1. Access Keys Authentication
35+
36+
Use AWS access keys for authentication. This is the traditional method using an access key ID and secret access key.
37+
38+
```sql
39+
CREATE CONNECTION <connection_name>
40+
STORAGE_TYPE = 's3'
41+
ACCESS_KEY_ID = '<your-access-key-id>'
42+
SECRET_ACCESS_KEY = '<your-secret-access-key>';
43+
```
44+
45+
| Parameter | Description |
46+
|-----------|-------------|
47+
| ACCESS_KEY_ID | Your AWS access key ID. |
48+
| SECRET_ACCESS_KEY | Your AWS secret access key. |
49+
50+
#### 2. IAM Role Authentication
51+
52+
Use AWS IAM roles for authentication instead of access keys. This provides a more secure way to access your S3 buckets without managing credentials directly in Databend.
53+
54+
```sql
55+
CREATE CONNECTION <connection_name>
56+
STORAGE_TYPE = 's3'
57+
ROLE_ARN = '<your-role-arn>';
58+
```
59+
60+
| Parameter | Description |
61+
|-----------|-------------|
62+
| ROLE_ARN | The Amazon Resource Name (ARN) of the IAM role that Databend will assume to access your S3 resources. |
63+
2464

2565
## Examples
2666

67+
### Using Access Keys
68+
2769
This example creates a connection to Amazon S3 named 'toronto' and establishes an external stage named 'my_s3_stage' linked to the 's3://databend-toronto' URL, using the 'toronto' connection. For more practical examples about connection, see [Usage Examples](index.md#usage-examples).
2870

2971
```sql
@@ -35,4 +77,25 @@ CREATE CONNECTION toronto
3577
CREATE STAGE my_s3_stage
3678
URL = 's3://databend-toronto'
3779
CONNECTION = (CONNECTION_NAME = 'toronto');
38-
```
80+
```
81+
82+
### Using AWS IAM Role
83+
84+
This example creates a connection to Amazon S3 using an IAM role and then creates a stage that uses this connection. This approach is more secure as it doesn't require storing access keys in Databend.
85+
86+
```sql
87+
CREATE CONNECTION databend_test
88+
STORAGE_TYPE = 's3'
89+
ROLE_ARN = 'arn:aws:iam::987654321987:role/databend-test';
90+
91+
CREATE STAGE databend_test
92+
URL = 's3://test-bucket-123'
93+
CONNECTION = (CONNECTION_NAME = 'databend_test');
94+
95+
-- You can now query data from your S3 bucket
96+
SELECT * FROM @databend_test/test.parquet LIMIT 1;
97+
```
98+
99+
:::info
100+
To use IAM roles with Databend Cloud, you need to set up a trust relationship between your AWS account and Databend Cloud. See [Creating External Stage with AWS IAM Role](/guides/load-data/stage/aws-iam-role) for detailed instructions.
101+
:::

0 commit comments

Comments
 (0)