Skip to content

Commit

Permalink
feat(resolves #32): Allow AES256
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Kaestle committed Sep 9, 2024
1 parent 10c98b0 commit 76c9540
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bucket_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data "aws_iam_policy_document" "bucket_policy_document" {
condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption"
values = ["AES256", "aws:kms"]
values = [local.kms_key_type]
}
principals {
type = "*"
Expand Down
1 change: 1 addition & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ locals {
current_account_id = data.aws_caller_identity.current.account_id
current_region = data.aws_region.current.id
do_cloudfront_policy = length(var.cloudfront_distribution_arns) > 0
kms_key_type = local.use_owned_kms || !var.use_aws_owned_kms ? "aws:kme" : "AES256"
use_owned_kms = var.kms_key_arn != ""
common_tags = {
"github:module:repository" = "flagscript/terraform-aws-flagscript-s3-bucket"
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_encryption
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = local.use_owned_kms ? var.kms_key_arn : null
sse_algorithm = "aws:kms"
sse_algorithm = local.kms_key_type
}
bucket_key_enabled = var.enable_bucket_key
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ variable "object_ownership" {
error_message = "Variable object_ownership must be a valid value."
}
}

variable "use_aws_owned_kms" {
default = false
description = "If kms_key_arn is not provided, use AES256 over aws/s3 aws managed key."
type = bool
}

0 comments on commit 76c9540

Please sign in to comment.