-
Notifications
You must be signed in to change notification settings - Fork 336
adding support to use a kms key for s3 buckets data encryption (AWS only) #2802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
67fdaca
5cd4c4d
7db0a87
cf4ec3e
ffbe979
5a0f3eb
708630c
3a10f7d
543dabc
351dc07
b8dad37
6feb766
d0907a1
e026c78
7c33b55
65a84fb
b8bacb9
8850df1
83115fd
b604568
d85e4cf
420c509
a7d6413
e4c8260
ab5cdf0
7192c2f
4b2dcd3
5da097a
8bd5b74
8a1fe7e
5a60a69
2e882bf
2addad4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,7 @@ public AccessConfig getSubscopedCreds( | |
| .roleSessionName("PolarisAwsCredentialsStorageIntegration") | ||
| .policy( | ||
| policyString( | ||
| storageConfig.getAwsPartition(), | ||
| storageConfig, | ||
| allowListOperation, | ||
| allowedReadLocations, | ||
| allowedWriteLocations) | ||
|
|
@@ -163,9 +163,8 @@ private boolean shouldUseSts(AwsStorageConfigurationInfo storageConfig) { | |
| * ListBucket privileges with no resources. This prevents us from sending an empty policy to AWS | ||
| * and just assuming the role with full privileges. | ||
| */ | ||
| // TODO - add KMS key access | ||
| private IamPolicy policyString( | ||
| String awsPartition, | ||
| AwsStorageConfigurationInfo storageConfigurationInfo, | ||
| boolean allowList, | ||
| Set<String> readLocations, | ||
| Set<String> writeLocations) { | ||
|
|
@@ -178,7 +177,10 @@ private IamPolicy policyString( | |
| Map<String, IamStatement.Builder> bucketListStatementBuilder = new HashMap<>(); | ||
| Map<String, IamStatement.Builder> bucketGetLocationStatementBuilder = new HashMap<>(); | ||
|
|
||
| String arnPrefix = arnPrefixForPartition(awsPartition); | ||
| String arnPrefix = arnPrefixForPartition(storageConfigurationInfo.getAwsPartition()); | ||
| String kmsKeyArn = storageConfigurationInfo.getKmsKeyArn(); | ||
|
||
| addKmsKeyPolicy(kmsKeyArn, policyBuilder); | ||
|
|
||
| Stream.concat(readLocations.stream(), writeLocations.stream()) | ||
| .distinct() | ||
| .forEach( | ||
|
|
@@ -242,6 +244,21 @@ private IamPolicy policyString( | |
| return policyBuilder.addStatement(allowGetObjectStatementBuilder.build()).build(); | ||
| } | ||
|
|
||
| private static void addKmsKeyPolicy(String kmsKeyArn, IamPolicy.Builder policyBuilder) { | ||
| if (kmsKeyArn != null) { | ||
| IamStatement.Builder allowKms = | ||
| IamStatement.builder() | ||
| .effect(IamEffect.ALLOW) | ||
| .addAction("kms:GenerateDataKeyWithoutPlaintext") | ||
| .addAction("kms:Encrypt") | ||
| .addAction("kms:DescribeKey") | ||
| .addAction("kms:Decrypt") | ||
|
||
| .addAction("kms:GenerateDataKey"); | ||
|
||
| allowKms.addResource(IamResource.create(kmsKeyArn)); | ||
| policyBuilder.addStatement(allowKms.build()); | ||
| } | ||
| } | ||
|
|
||
| private static String arnPrefixForPartition(String awsPartition) { | ||
| return String.format("arn:%s:s3:::", awsPartition != null ? awsPartition : "aws"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1103,6 +1103,10 @@ components: | |
| type: string | ||
| description: the aws user arn used to assume the aws role | ||
| example: "arn:aws:iam::123456789001:user/abc1-b-self1234" | ||
| kmsKeyArn: | ||
|
||
| type: string | ||
| description: the aws kms key arn used to encrypt s3 data | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by s3 data we mean data stored in s3 or iceberg data files ? if its just iceberg data files how are we making sure its not used against iceberg metadata files such as manifest lists ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the key is used by s3 to do encryption of any data in the bucket at rest, so as long as the IAM role has got the right entitlements on the key everything will work fine. I don't think anything needs to be changed on the polaris side.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am talking of setting these properties in the FileIO which polaris uses - https://iceberg.apache.org/docs/nightly/aws/#s3-server-side-encryption or are you relying on these catalog properties seeping automatically to the FileIO
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow I might be missing something, how would you specify the kms key in Polaris without adding in the storage config, also we need to add the policy in there to be able to use right? thx |
||
| example: "arn:aws:kms::123456789001:key/01234578" | ||
| region: | ||
| type: string | ||
| description: the aws region where data is stored | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.