Skip to content

Commit 52e305f

Browse files
committed
add docs
1 parent 5382230 commit 52e305f

File tree

1 file changed

+21
-5
lines changed
  • docs/en/sql-reference/table-functions

1 file changed

+21
-5
lines changed

docs/en/sql-reference/table-functions/s3.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,21 @@ SELECT count() FROM s3('https://datasets-documentation.s3.eu-west-3.amazonaws.co
272272

273273
## Role Assumption
274274

275-
ClickHouse supports assuming an AWS IAM role using a set of AWS credentials (`access_key_id`, `secret_access_key`, `session_token`).
276-
This allows ClickHouse to obtain temporary credentials for accessing an S3 bucket, even if the original credentials do not have direct access.
275+
ClickHouse supports assuming an AWS IAM role using a set of AWS credentials (`access_key_id`, `secret_access_key`, `session_token`) or EC2 metadata (only when running on EC2 instance).
276+
This allows ClickHouse to obtain temporary credentials for accessing an S3 bucket, even if the original credentials or instance do not have direct access.
277277

278278
For example, if the provided credentials have permission to assume a role but lack direct access to the S3 bucket, ClickHouse will first request temporary credentials from AWS STS and then use those credentials to access S3.
279279

280280
For more details on role assumption, read [AWS AssumeRole documentation](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html).
281281

282-
To enable role assumption, pass parameters via the extra_credentials argument in the s3 function. The following keys are supported:
282+
To use this mechanism, pass parameters via the `extra_credentials` argument to the `s3` function. The following keys are supported:
283283

284-
* `role_arn` (required) — ARN of the IAM role to assume. **If this key is not provided, ClickHouse will not attempt to assume a role and will use the original credentials as-is.**
285-
* `role_session_name` (optional) — Custom session name to include in the AssumeRole request.
284+
* `role_arn` (required) — ARN of the IAM role to assume. **If this key is not provided, ClickHouse will not attempt to assume a role and will try to access the bucket as-is.**
285+
* `role_session_name` (optional) — Custom session name to include in the AssumeRole request. If not specified, a random UUID will be assigned.
286286
* `sts_endpoint_override` (optional) — Overrides the default AWS STS endpoint (https://sts.amazonaws.com). Useful for testing with a mock or when using another STS-compatible service.
287287

288+
If explicit `access_key_id` and `secret_access_key` are provided as parameters to `s3(...)` function, then they will be used for retrieving temporary credentials from STS:
289+
288290
```sql
289291
SELECT count() FROM s3(
290292
'<s3_bucket_uri>/*.csv',
@@ -298,6 +300,20 @@ SELECT count() FROM s3(
298300
)
299301
)
300302
```
303+
304+
Otherwise, ClickHouse will attempt to extract credentials from EC2 metadata:
305+
306+
```sql
307+
SELECT count() FROM s3(
308+
'<s3_bucket_uri>/*.csv',
309+
'CSVWithNames',
310+
extra_credentials(
311+
role_arn = 'arn:aws:iam::111111111111:role/BucketAccessRole-001',
312+
role_session_name = 'ClickHouseSession'
313+
)
314+
)
315+
```
316+
301317
Further examples can be found [here](/docs/cloud/security/secure-s3#access-your-s3-bucket-with-the-clickhouseaccess-role)
302318

303319
## Working with archives

0 commit comments

Comments
 (0)