Skip to content

Update sseType when creating S3Context with KmsKeyId#23299

Merged
electrum merged 1 commit intotrinodb:masterfrom
Praveen2112:praveen/fs_changes
Sep 5, 2024
Merged

Update sseType when creating S3Context with KmsKeyId#23299
electrum merged 1 commit intotrinodb:masterfrom
Praveen2112:praveen/fs_changes

Conversation

@Praveen2112
Copy link
Copy Markdown
Member

SSE configuration is not applied correctly if we have a S3SecurityMapping which configures kmsKeyId for a given user and the default S3 Config has s3.sse.type set to NONE or S3.

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
(x) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

# Section
* Fix SSE configuration when using S3SecurityMapping with kmsKeyId configured

SSE configuration is not applied correctly if we have a S3SecurityMapping which
configures kmsKeyId for a given user and the default S3 Config has `s3.sse.type`
set to NONE or S3.

public S3Context withKmsKeyId(String kmsKeyId)
{
return new S3Context(partSize, requesterPays, sseType, kmsKeyId, credentialsProviderOverride, cannedAcl, exclusiveWriteSupported);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify(sseType == NONE, "Cannot set KMS when sseType is %s", sseType)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's verify it properly

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it would have a restriction on S3SecurityMapping side that all the buckets should be under this KMS - For instance we could have one bucket which has S3 security mapping and we could have one bucket which could have KMS type SSE which could be mapped to specific users - If we add a verification they we might not be able access bucket with different SSE settings. Or am I missing something here ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the filesystem created per bucket?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of S3SecurityMapping or in general ? But the configs are shared right ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the TrinoFileSystemFactory is created once at injection time and then TrinoFileSystem is created at each usage site with ConnectorIdentity.

S3 security mapping uses SwitchingFileSystemFactory with S3FileSystemLoader to create a separate S3SecurityMappingFileSystemFactory per location.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is correct. The purpose of S3 security mapping is to override the security settings for that mapping. So you could configure s3.sse.type=S3 as the global default and override for a specific bucket, path, etc.


public S3Context withKmsKeyId(String kmsKeyId)
{
return new S3Context(partSize, requesterPays, sseType, kmsKeyId, credentialsProviderOverride, cannedAcl, exclusiveWriteSupported);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is correct. The purpose of S3 security mapping is to override the security settings for that mapping. So you could configure s3.sse.type=S3 as the global default and override for a specific bucket, path, etc.

@electrum electrum merged commit 84c8b9f into trinodb:master Sep 5, 2024
@github-actions github-actions bot added this to the 456 milestone Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants