Skip to main content

S3 file system support

Trino includes a native implementation to access Amazon S3 and compatible storage systems with a catalog using the Delta Lake, Hive, Hudi, or Iceberg connectors. While Trino is designed to support S3-compatible storage systems, only AWS S3 and MinIO are tested for compatibility. For other storage systems, perform your own testing and consult your vendor for more information.

Enable the native implementation with fs.s3.enabled=true in your catalog properties file.

General configuration

Use the following properties to configure general aspects of S3 file system support:

PropertyDescription
fs.s3.enabledActivate the native implementation for S3 storage support. Defaults to false. Set to true to use S3 and enable all other properties.
s3.endpointS3 service endpoint URL to communicate with.
s3.regionS3 region to communicate with.
s3.cross-region-accessEnable cross region access. Defaults to false.
s3.path-style-accessUse path-style access for all requests to S3
s3.storage-classS3 storage class to use while writing data. Defaults to STANDARD. Other allowed values are: STANDARD_IA, INTELLIGENT_TIERING, REDUCED_REDUNDANCY, ONEZONE_IA, GLACIER, DEEP_ARCHIVE, OUTPOSTS, GLACIER_IR, SNOW, EXPRESS_ONEZONE.
s3.signer-typeAWS signing protocol to use for authenticating S3 requests. Supported values are: AwsS3V4Signer, Aws4Signer, AsyncAws4Signer, Aws4UnsignedPayloadSigner, EventStreamAws4Signer.
s3.canned-aclCanned ACL to use when uploading files to S3. Defaults to NONE, which has the same effect as PRIVATE. If the files are to be uploaded to an S3 bucket owned by a different AWS user, the canned ACL may be set to one of the following: PRIVATE, PUBLIC_READ, PUBLIC_READ_WRITE, AUTHENTICATED_READ, BUCKET_OWNER_READ, or BUCKET_OWNER_FULL_CONTROL.
s3.sse.typeSet the type of S3 server-side encryption (SSE) to use. Defaults to NONE for no encryption. Other valid values are S3 for encryption by S3 managed keys, KMS for encryption with a key from the AWS Key Management Service (KMS), and CUSTOMER for encryption with a customer-provided key from s3.sse.customer-key. Note that S3 automatically uses SSE so NONE and S3 are equivalent. S3-compatible systems might behave differently.
s3.sse.kms-key-idThe identifier of a key in KMS to use for SSE.
s3.sse.customer-keyThe 256-bit, base64-encoded AES-256 encryption key to encrypt or decrypt data from S3 when using the SSE-C mode for SSE with s3.sse.type set to CUSTOMER.
s3.streaming.part-sizePart size for S3 streaming upload. Values between 5MB and 256MB are valid. Defaults to 32MB.
s3.requester-paysSwitch to activate billing transfer cost to the requester. Defaults to false.
s3.max-connectionsMaximum number of connections to S3. Defaults to 500.
s3.connection-ttlMaximum time duration allowed to reuse connections in the connection pool before being replaced.
s3.connection-max-idle-timeMaximum time duration allowed for connections to remain idle in the connection pool before being closed.
s3.socket-connect-timeoutMaximum time duration allowed for socket connection requests to complete before timing out.
s3.socket-timeoutMaximum time duration for socket read/write operations before timing out.
s3.tcp-keep-aliveEnable TCP keep alive on created connections. Defaults to false.
s3.http-proxyURL of a HTTP proxy server to use for connecting to S3.
s3.http-proxy.secureSet to true to enable HTTPS for the proxy server.
s3.http-proxy.usernameProxy username to use if connecting through a proxy server.
s3.http-proxy.passwordProxy password to use if connecting through a proxy server.
s3.http-proxy.non-proxy-hostsHosts list to access without going through the proxy server.
s3.http-proxy.preemptive-basic-authWhether to attempt to authenticate preemptively against proxy server when using base authorization, defaults to false.
s3.retry-modeSpecifies how the AWS SDK attempts retries. Default value is LEGACY. Other allowed values are STANDARD and ADAPTIVE. The STANDARD mode includes a standard set of errors that are retried. ADAPTIVE mode includes the functionality of STANDARD mode with automatic client-side throttling.
s3.max-error-retriesSpecifies maximum number of retries the client will make on errors. Defaults to 20.
s3.application-idSpecify the application identifier appended to the User-Agent header for all requests sent to S3. Defaults to Trino.

Authentication

Use the following properties to configure the authentication to S3 with access and secret keys, STS, or an IAM role. The access key, secret key, STS, and external ID properties are only used by the DEFAULT and IAM_ROLE authentication modes; setting any of them for ANONYMOUS or WEB_IDENTITY fails at startup.

PropertyDescription
s3.aws-access-keyAWS access key to use for authentication.
s3.aws-secret-keyAWS secret key to use for authentication.
s3.sts.endpointThe endpoint URL of the AWS Security Token Service to use for authenticating to S3.
s3.sts.regionAWS region of the STS service.
s3.iam-roleARN of an IAM role to assume when connecting to S3. Requires s3.auth-type=IAM_ROLE.
s3.role-session-nameRole session name to use when connecting to S3. Defaults to trino-filesystem.
s3.external-idExternal ID for the IAM role trust policy when connecting to S3.
s3.auth-typeAuthentication mode for accessing S3, one of:
- ANONYMOUS: sends no credentials, for reading public buckets. - DEFAULT (default): uses the static access keys when set, otherwise the AWS default credentials chain. Security mapping roles are still honored. - IAM_ROLE: assumes the IAM role configured in s3.iam-role. - WEB_IDENTITY: uses the web identity token file credentials provider instead of the default credentials chain. Useful when running Trino on Amazon EKS with IAM roles for service accounts (IRSA).

Security mapping

Trino supports flexible security mapping for S3, allowing for separate credentials or IAM roles for specific users or S3 locations. The IAM role for a specific query can be selected from a list of allowed roles by providing it as an extra credential.

Each security mapping entry may specify one or more match criteria. If multiple criteria are specified, all criteria must match. The following match criteria are available:

  • user: Regular expression to match against username. Example: alice|bob
  • group: Regular expression to match against any of the groups that the user belongs to. Example: finance|sales
  • prefix: S3 URL prefix. You can specify an entire bucket or a path within a bucket. The URL must start with s3:// but also matches for s3a or s3n. Example: s3://bucket-name/abc/xyz/

The security mapping must provide one or more configuration settings:

  • accessKey and secretKey: AWS access key and secret key. This overrides any globally configured credentials, such as access key or instance credentials.
  • iamRole: IAM role to use if no user provided role is specified as an extra credential. This overrides any globally configured IAM role. This role is allowed to be specified as an extra credential, although specifying it explicitly has no effect.
  • roleSessionName: Optional role session name to use with iamRole. This can only be used when iamRole is specified. If roleSessionName includes the string ${USER}, then the ${USER} portion of the string is replaced with the current session's username. If roleSessionName is not specified, it defaults to trino-session.
  • allowedIamRoles: IAM roles that are allowed to be specified as an extra credential. This is useful because a particular AWS account may have permissions to use many roles, but a specific user should only be allowed to use a subset of those roles.
  • kmsKeyId: ID of KMS-managed key to be used for client-side encryption.
  • allowedKmsKeyIds: KMS-managed key IDs that are allowed to be specified as an extra credential. If list contains *, then any key can be specified via extra credential.
  • sseCustomerKey: The customer provided key (SSE-C) for server-side encryption.
  • allowedSseCustomerKey: The SSE-C keys that are allowed to be specified as an extra credential. If list contains *, then any key can be specified via extra credential.
  • endpoint: The S3 storage endpoint server. This optional property can be used to override S3 endpoints on a per-bucket basis.
  • region: The S3 region to connect to. This optional property can be used to override S3 regions on a per-bucket basis.

The security mapping entries are processed in the order listed in the JSON configuration. Therefore, specific mappings must be specified before less specific mappings. For example, the mapping list might have URL prefix s3://abc/xyz/ followed by s3://abc/ to allow different configuration for a specific path within a bucket than for other paths within the bucket. You can specify the default configuration by not including any match criteria for the last entry in the list.

In addition to the preceding rules, the default mapping can contain the optional useClusterDefault boolean property set to true to use the default S3 configuration. It cannot be used with any other configuration settings.

If no mapping entry matches and no default is configured, access is denied.

The configuration JSON is read from a file via s3.security-mapping.config-file or from an HTTP endpoint via s3.security-mapping.config-uri.

Example JSON configuration:

{
"mappings": [
{
"prefix": "s3://bucket-name/abc/",
"iamRole": "arn:aws:iam::123456789101:role/test_path"
},
{
"user": "bob|charlie",
"iamRole": "arn:aws:iam::123456789101:role/test_default",
"allowedIamRoles": [
"arn:aws:iam::123456789101:role/test1",
"arn:aws:iam::123456789101:role/test2",
"arn:aws:iam::123456789101:role/test3"
]
},
{
"prefix": "s3://special-bucket/",
"accessKey": "AKIAxxxaccess",
"secretKey": "iXbXxxxsecret"
},
{
"prefix": "s3://regional-bucket/",
"iamRole": "arn:aws:iam::123456789101:role/regional-user",
"endpoint": "https://bucket.vpce-1a2b3c4d-5e6f.s3.us-east-1.vpce.amazonaws.com",
"region": "us-east-1"
},
{
"prefix": "s3://encrypted-bucket/",
"kmsKeyId": "kmsKey_10"
},
{
"user": "test.*",
"iamRole": "arn:aws:iam::123456789101:role/test_users"
},
{
"group": "finance",
"iamRole": "arn:aws:iam::123456789101:role/finance_users"
},
{
"iamRole": "arn:aws:iam::123456789101:role/default"
}
]
}

Security mapping properties

Property nameDescription
s3.security-mapping.enabledActivate the security mapping feature. Defaults to false. Must be set to true for all other properties be used.
s3.security-mapping.config-filePath to the JSON configuration file containing security mappings.
s3.security-mapping.config-uriHTTP endpoint URI containing security mappings.
s3.security-mapping.json-pointerA JSON pointer (RFC 6901) to mappings inside the JSON retrieved from the configuration file or HTTP endpoint. The default is the root of the document.
s3.security-mapping.iam-role-credential-nameThe name of the extra credential used to provide the IAM role.
s3.security-mapping.kms-key-id-credential-nameThe name of the extra credential used to provide the KMS-managed key ID.
s3.security-mapping.sse-customer-key-credential-nameThe name of the extra credential used to provide the server-side encryption with customer-provided keys (SSE-C).
s3.security-mapping.refresh-periodHow often to refresh the security mapping configuration, specified as a Properties reference. By default, the configuration is not refreshed.
s3.security-mapping.colon-replacementThe character or characters to be used instead of a colon character when specifying an IAM role name as an extra credential. Any instances of this replacement value in the extra credential value are converted to a colon. Choose a value not used in any of your IAM ARNs.

Migration from legacy S3 file system

Previous Trino releases included a legacy Amazon S3 file system implementation used by catalogs configured with fs.hadoop.enabled and hive.s3.* properties. That legacy support has been removed. Use the native S3 file system implementation.

To migrate a catalog to use the native file system implementation for S3, make the following edits to your catalog configuration:

  1. Add the fs.s3.enabled=true catalog configuration property.
  2. If your catalog enabled fs.hadoop.enabled only for legacy S3 access, remove that property.
  3. Refer to the following table to rename your existing legacy catalog configuration properties to the corresponding native configuration properties. Supported configuration values are identical unless otherwise noted.
Legacy propertyNative propertyNotes
hive.s3.aws-access-keys3.aws-access-key
hive.s3.aws-secret-keys3.aws-secret-key
hive.s3.iam-roles3.iam-roleAlso see s3.role-session-name in preceding sections for more role configuration options.
hive.s3.external-ids3.external-id
hive.s3.endpoints3.endpointAdd the https:// prefix to make the value a correct URL.
hive.s3.regions3.region
hive.s3.sse.enabledNones3.sse.type set to the default value of NONE is equivalent to hive.s3.sse.enabled=false.
hive.s3.sse.types3.sse.type
hive.s3.sse.kms-key-ids3.sse.kms-key-id
hive.s3.upload-acl-types3.canned-aclSee preceding sections for supported values.
hive.s3.streaming.part-sizes3.streaming.part-size
hive.s3.proxy.host, hive.s3.proxy.ports3.http-proxySpecify the host and port in one URL, for example localhost:8888.
hive.s3.proxy.protocols3.http-proxy.secureSet to TRUE to enable HTTPS.
hive.s3.proxy.non-proxy-hostss3.http-proxy.non-proxy-hosts
hive.s3.proxy.usernames3.http-proxy.username
hive.s3.proxy.passwords3.http-proxy.password
hive.s3.proxy.preemptive-basic-auths3.http-proxy.preemptive-basic-auth
hive.s3.sts.endpoints3.sts.endpoint
hive.s3.sts.regions3.sts.region
hive.s3.max-error-retriess3.max-error-retriesAlso see s3.retry-mode in preceding sections for more retry behavior configuration options.
hive.s3.connect-timeouts3.socket-connect-timeout
hive.s3.connect-ttls3.connection-ttlAlso see s3.connection-max-idle-time in preceding section for more connection keep-alive options.
hive.s3.socket-timeouts3.socket-timeoutAlso see s3.tcp-keep-alive in preceding sections for more socket connection keep-alive options.
hive.s3.max-connectionss3.max-connections
hive.s3.path-style-accesss3.path-style-access
hive.s3.signer-types3.signer-type
  1. Remove the following legacy configuration properties if they exist in your catalog configuration:

    • hive.s3.storage-class
    • hive.s3.signer-class
    • hive.s3.staging-directory
    • hive.s3.pin-client-to-current-region
    • hive.s3.ssl.enabled
    • hive.s3.sse.enabled
    • hive.s3.kms-key-id
    • hive.s3.encryption-materials-provider
    • hive.s3.streaming.enabled
    • hive.s3.max-client-retries
    • hive.s3.max-backoff-time
    • hive.s3.max-retry-time
    • hive.s3.multipart.min-file-size
    • hive.s3.multipart.min-part-size
    • hive.s3-file-system-type
    • hive.s3.user-agent-prefix