-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add CMK encryption support to DynamoDB export #3592
Changes from all commits
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 |
---|---|---|
|
@@ -6,21 +6,25 @@ | |
package org.opensearch.dataprepper.plugins.source.dynamodb.configuration; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.constraints.AssertTrue; | ||
import jakarta.validation.constraints.NotBlank; | ||
import software.amazon.awssdk.arns.Arn; | ||
import software.amazon.awssdk.regions.Region; | ||
|
||
public class ExportConfig { | ||
|
||
@JsonProperty("s3_bucket") | ||
@NotBlank(message = "Bucket Name is required for export") | ||
private String s3Bucket; | ||
|
||
@JsonProperty("s3_prefix") | ||
private String s3Prefix; | ||
|
||
@JsonProperty("s3_region") | ||
private String s3Region; | ||
|
||
@JsonProperty("s3_sse_kms_key_id") | ||
private String s3SseKmsKeyId; | ||
|
||
public String getS3Bucket() { | ||
return s3Bucket; | ||
} | ||
|
@@ -33,4 +37,15 @@ public Region getAwsRegion() { | |
return s3Region != null ? Region.of(s3Region) : null; | ||
} | ||
|
||
public String getS3SseKmsKeyId() { | ||
return s3SseKmsKeyId; | ||
} | ||
|
||
@AssertTrue(message = "KMS Key ID must be a valid one.") | ||
boolean isKmsKeyIdValid() { | ||
// If key id is provided, it should be in a format like | ||
// arn:aws:kms:us-west-2:123456789012:key/0a4bc22f-bb96-4ad3-80ca-63b12b3ec147 | ||
return s3SseKmsKeyId == null || Arn.fromString(s3SseKmsKeyId).resourceAsString() != null; | ||
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 we really want this validation to be so strict. Users should be allowed to provide KMS keys as aliases. e.g. 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 don't agree with this. Even from DynamoDB console, there is no way to provide an aliaes, can only provide KMS Key ID. Note that alias is optional to KMS CMK. I believe you want more flexibility here, but to get Key ID (which is used in the API call) by alias, we will need to have more permissions (maybe describe keys or something). 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. Also alias may not work for multi-region keys. 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. @daixba , Typically AWS services allow for either specifying an alias or an ARN. So my ask is not to require the user to provide an alias. It is to allow the user to provide either an ARN or an alias. The documentation on this is unclear, but their restrictions indicate a minimum length of 1 which is compatible with an alias. We shouldn't follow the Console, but what the API itself allows. If this API does not permit an alias, then I agree this should be only an ARN. But, it appears to support the alias. 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. We should probably wrap this in a try catch to avoid NPE's and exceptions from just throwing here with invalid ARN format, but this can be added as a follow on |
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have at least three options starting with
s3_
. It may be ideal to make thiss3:
since we haven't yet released this feature.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be confused this way, it seems more options are supported apart from S3.
So I think it's better if we just align this with the API structure: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExportTableToPointInTime.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense - I'm ok with this.