Skip to content

Commit

Permalink
encrypt cloudtrail bucket by default
Browse files Browse the repository at this point in the history
  • Loading branch information
smelchior committed Dec 21, 2017
1 parent a95361a commit 1b92764
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
provider "aws" {
region = "${var.aws_region}"
version = "~> 1.6"
}
9 changes: 9 additions & 0 deletions s3_cloudtrail.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ resource "aws_s3_bucket" "cloudtrail_bucket" {
bucket = "${local.bucket_name}"
acl = "private"
count = "${var.trail_bucketname_create}"

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = "${var.trail_bucket_default_encryption_key}"
sse_algorithm = "${var.trail_bucket_default_encryption}"
}
}
}
}

resource "aws_s3_bucket_policy" "cloudtrail_bucket_policy" {
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ variable "trail_bucketname_create" {
description = "Defines if the bucket should be created."
default = 1
}

variable "trail_bucket_default_encryption" {
description = "Defines if the Bucket is encrypted, defaults to AES256"
default = "AES256"
}

variable "trail_bucket_default_encryption_key" {
description = "Defines if the KMS encryption key, used if trail_bucket_default_encryption is set to aws:kms"
default = ""
}

0 comments on commit 1b92764

Please sign in to comment.