@@ -33,80 +33,25 @@ CREATE STAGE [ IF NOT EXISTS ] <external_stage_name>
33
33
34
34
### externalStageParams
35
35
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.
55
38
:::
56
- </TabItem >
57
-
58
- <TabItem value =" Azure Blob Storage " label =" Azure Blob Storage " >
59
39
60
40
``` sql
61
41
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>'
76
43
CONNECTION = (
77
44
< connection_parameters>
78
45
)
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
+ |
89
47
CONNECTION = (
90
- < connection_parameters >
91
- )
48
+ CONNECTION_NAME = ' <your-connection-name> '
49
+ );
92
50
```
93
51
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 ) .
96
53
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 ) .
110
55
111
56
### FILE_FORMAT
112
57
@@ -151,12 +96,21 @@ my_internal_stage|Internal |StageParams { storage: Fs(StorageFsConfig { root: "
151
96
152
97
```
153
98
154
- ### Example 2: Create External Stage with AWS Access Key
99
+ ### Example 2: Create External Stage with Connection
155
100
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 :
157
102
158
103
``` 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' );
160
114
161
115
DESC STAGE my_s3_stage;
162
116
+ -- -----------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------+---------+
@@ -218,10 +172,19 @@ The procedure below creates an IAM user named *databend* and attach the access p
218
172
219
173
#### Step 3: Create External Stage
220
174
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 .
222
176
223
177
``` 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' );
225
188
```
226
189
227
190
### 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
249
212
Use the created Access Key ID and Secret Access Key to create an external stage named * r2_stage* .
250
213
251
214
``` 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
252
224
CREATE STAGE r2_stage
253
225
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' );
259
227
```
0 commit comments