Skip to content
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

feat: add support for kms replication of objects #787

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions aws/components/s3/setup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
[#local replicationCrossAccount = false ]
[#local replicationDestinationAccountId = "" ]
[#local replicationExternalPolicy = []]
[#local replicationKMSKey = ""]

[#local backupTags = {} ]

Expand Down Expand Up @@ -296,9 +297,16 @@
[#local replicationEnabled = true]
[#local versioningEnabled = true]

[#local replicationDestinationAccountId = linkTargetAttributes["ACCOUNT_ID"]!"" ]
[#local replicationDestinationAccountId = (linkTargetAttributes["ACCOUNT_ID"])!"" ]
[#local replicationExternalPolicy += s3ReplicaDestinationPermission( linkTargetAttributes["ARN"] ) ]
[#local replicationBucket = linkTargetAttributes["ARN"]]
[#local replicationKMSKey = (linkTargetAttributes["KMS_KEY_ARN"])!""]
[#local replicationKMSKeyARN = (linkTargetAttributes["KMS_KEY_REGION"])!""]

[#if replicationKMSKey?has_content ]
[#local replicationExternalPolicy += s3EncryptionAllPermission(replicationKMSKey, replicationBucket, "*", replicationKMSKeyARN)]
[/#if]

[#break]

[#case "save" ]
Expand Down Expand Up @@ -394,7 +402,10 @@
solution.Replication.Enabled,
prefix,
replicateEncryptedData,
kmsKeyId,
replicationKMSKey?has_content?then(
replicationKMSKey,
kmsKeyId
),
replicationDestinationAccountId
)]]
[/#list]
Expand Down
8 changes: 7 additions & 1 deletion aws/services/kms/policy.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
"",
{
"StringLike" : {
"kms:EncryptionContext:aws:s3:arn" : "arn:aws:s3:::" + formatRelativePath(bucketName, bucketPrefix?ensure_ends_with("*") )
"kms:EncryptionContext:aws:s3:arn" : formatRelativePath(
bucketName?is_string?then(
bucketName?ensure_starts_with("arn:aws:s3:::"),
bucketName
),
bucketPrefix?ensure_ends_with("*")
)
}
}
)
Expand Down
1 change: 1 addition & 0 deletions aws/services/s3/policy.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
[#return
getS3Statement(
[
"s3:PutObject",
"s3:ReplicateObject",
"s3:ReplicateDelete",
"s3:ObjectOwnerOverrideToBucketOwner",
Expand Down