Skip to content

Commit 9be0e29

Browse files
authored
Revise external stage creation examples and parameters
Updated examples and parameters for creating external stages using connections instead of inline credentials for better security.
1 parent e6c56e6 commit 9be0e29

File tree

1 file changed

+41
-73
lines changed

1 file changed

+41
-73
lines changed

docs/en/sql-reference/10-sql-commands/00-ddl/03-stage/01-ddl-create-stage.md

Lines changed: 41 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -33,80 +33,25 @@ CREATE STAGE [ IF NOT EXISTS ] <external_stage_name>
3333

3434
### externalStageParams
3535

36-
import Tabs from '@theme/Tabs';
37-
import TabItem from '@theme/TabItem';
38-
39-
<Tabs groupId="externalstageparams">
40-
41-
<TabItem value="Amazon S3-compatible Storage" label="Amazon S3-like Storage Services">
42-
43-
```sql
44-
externalStageParams ::=
45-
's3://<bucket>[<path/>]'
46-
CONNECTION = (
47-
<connection_parameters>
48-
)
49-
```
50-
51-
For the connection parameters available for accessing Amazon S3-like storage services, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
52-
53-
:::note
54-
To create an external stage on Amazon S3, you can also use an IAM user account, enabling you to define fine-grained access controls for the stage, including specifying actions such as read or write access to specific S3 buckets. See [Example 3: Create External Stage with AWS IAM User](#example-3-create-external-stage-with-aws-iam-user).
36+
:::tip
37+
For external stages, it is recommended to use the `CONNECTION` parameter to reference pre-configured connection objects instead of inline credentials. This approach provides better security and maintainability.
5538
:::
56-
</TabItem>
57-
58-
<TabItem value="Azure Blob Storage" label="Azure Blob Storage">
5939

6040
```sql
6141
externalStageParams ::=
62-
'azblob://<container>[<path/>]'
63-
CONNECTION = (
64-
<connection_parameters>
65-
)
66-
```
67-
68-
For the connection parameters available for accessing Azure Blob Storage, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
69-
</TabItem>
70-
71-
<TabItem value="Google Cloud Storage" label="Google Cloud Storage">
72-
73-
```sql
74-
externalLocation ::=
75-
'gcs://<bucket>[<path>]'
42+
'<protocol>://<location>'
7643
CONNECTION = (
7744
<connection_parameters>
7845
)
79-
```
80-
81-
For the connection parameters available for accessing Google Cloud Storage, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
82-
</TabItem>
83-
84-
<TabItem value="Alibaba Cloud OSS" label="Alibaba Cloud OSS">
85-
86-
```sql
87-
externalLocation ::=
88-
'oss://<bucket>[<path>]'
46+
|
8947
CONNECTION = (
90-
<connection_parameters>
91-
)
48+
CONNECTION_NAME = '<your-connection-name>'
49+
);
9250
```
9351

94-
For the connection parameters available for accessing Alibaba Cloud OSS, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
95-
</TabItem>
52+
For the connection parameters available for different storage services, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
9653

97-
<TabItem value="Tencent Cloud Object Storage" label="Tencent Cloud Object Storage">
98-
99-
```sql
100-
externalLocation ::=
101-
'cos://<bucket>[<path>]'
102-
CONNECTION = (
103-
<connection_parameters>
104-
)
105-
```
106-
107-
For the connection parameters available for accessing Tencent Cloud Object Storage, see [Connection Parameters](/00-sql-reference/51-connect-parameters.md).
108-
</TabItem>
109-
</Tabs>
54+
For more information on `CONNECTION_NAME`, see [CREATE CONNECTION](../13-connection/create-connection.md).
11055

11156
### FILE_FORMAT
11257

@@ -151,12 +96,21 @@ my_internal_stage|Internal |StageParams { storage: Fs(StorageFsConfig { root: "
15196

15297
```
15398

154-
### Example 2: Create External Stage with AWS Access Key
99+
### Example 2: Create External Stage with Connection
155100

156-
This example creates an external stage named *my_s3_stage* on Amazon S3:
101+
This example creates an external stage named *my_s3_stage* on Amazon S3 using a connection:
157102

158103
```sql
159-
CREATE STAGE my_s3_stage URL='s3://load/files/' CONNECTION = (ACCESS_KEY_ID = '<your-access-key-id>' SECRET_ACCESS_KEY = '<your-secret-access-key>');
104+
-- First create a connection
105+
CREATE CONNECTION my_s3_connection
106+
STORAGE_TYPE = 's3'
107+
ACCESS_KEY_ID = '<your-access-key-id>'
108+
SECRET_ACCESS_KEY = '<your-secret-access-key>';
109+
110+
-- Create stage using the connection
111+
CREATE STAGE my_s3_stage
112+
URL='s3://load/files/'
113+
CONNECTION = (CONNECTION_NAME = 'my_s3_connection');
160114

161115
DESC STAGE my_s3_stage;
162116
+-------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------+---------+
@@ -218,10 +172,19 @@ The procedure below creates an IAM user named *databend* and attach the access p
218172

219173
#### Step 3: Create External Stage
220174

221-
Use the access key and secret access key generated for the IAM user *databend* to create an external stage.
175+
Use the IAM role to create an external stage with better security.
222176

223177
```sql
224-
CREATE STAGE iam_external_stage url = 's3://databend-toronto' CONNECTION =(ACCESS_KEY_ID='<your-access-key-id>' SECRET_ACCESS_KEY='<your-secret-access-key>');
178+
-- First create a connection using IAM role
179+
CREATE CONNECTION iam_s3_connection
180+
STORAGE_TYPE = 's3'
181+
ROLE_ARN = 'arn:aws:iam::123456789012:role/databend-access'
182+
EXTERNAL_ID = 'my-external-id-123';
183+
184+
-- Create stage using the connection
185+
CREATE STAGE iam_external_stage
186+
URL = 's3://databend-toronto'
187+
CONNECTION = (CONNECTION_NAME = 'iam_s3_connection');
225188
```
226189

227190
### Example 4: Create External Stage on Cloudflare R2
@@ -249,11 +212,16 @@ The procedure below creates an R2 API token that includes an Access Key ID and a
249212
Use the created Access Key ID and Secret Access Key to create an external stage named *r2_stage*.
250213

251214
```sql
215+
-- First create a connection
216+
CREATE CONNECTION r2_connection
217+
STORAGE_TYPE = 's3'
218+
REGION = 'auto'
219+
ENDPOINT_URL = '<your-bucket-endpoint>'
220+
ACCESS_KEY_ID = '<your-access-key-id>'
221+
SECRET_ACCESS_KEY = '<your-secret-access-key>';
222+
223+
-- Create stage using the connection
252224
CREATE STAGE r2_stage
253225
URL='s3://databend/'
254-
CONNECTION = (
255-
REGION = 'auto'
256-
ENDPOINT_URL = '<your-bucket-endpoint>'
257-
ACCESS_KEY_ID = '<your-access-key-id>'
258-
SECRET_ACCESS_KEY = '<your-secret-access-key>');
226+
CONNECTION = (CONNECTION_NAME = 'r2_connection');
259227
```

0 commit comments

Comments
 (0)