Skip to content

Commit 267c4a4

Browse files
dmattiaaknysh
authored andcommitted
Added the option to add aes256 sse (#60)
My org, and I would imagine others, prefers to encrypt s3 buckets even when not entirely necessary just for uniformity in our internal security audits.
1 parent 0fd3840 commit 267c4a4

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Available targets:
162162
| default_ttl | Default amount of time (in seconds) that an object is in a CloudFront cache | string | `60` | no |
163163
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
164164
| enabled | Select Enabled if you want CloudFront to begin processing requests as soon as the distribution is created, or select Disabled if you do not want CloudFront to begin processing requests after the distribution is created. | bool | `true` | no |
165+
| encryption_enabled | When set to 'true' the resource will have aes256 encryption enabled by default | bool | `false` | no |
165166
| extra_logs_attributes | Additional attributes to put onto the log bucket label | list(string) | `<list>` | no |
166167
| extra_origin_attributes | Additional attributes to put onto the origin label | list(string) | `<list>` | no |
167168
| forward_cookies | Time in seconds that browser can cache the response for S3 bucket | string | `none` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| default_ttl | Default amount of time (in seconds) that an object is in a CloudFront cache | string | `60` | no |
2222
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `-` | no |
2323
| enabled | Select Enabled if you want CloudFront to begin processing requests as soon as the distribution is created, or select Disabled if you do not want CloudFront to begin processing requests after the distribution is created. | bool | `true` | no |
24+
| encryption_enabled | When set to 'true' the resource will have aes256 encryption enabled by default | bool | `false` | no |
2425
| extra_logs_attributes | Additional attributes to put onto the log bucket label | list(string) | `<list>` | no |
2526
| extra_origin_attributes | Additional attributes to put onto the origin label | list(string) | `<list>` | no |
2627
| forward_cookies | Time in seconds that browser can cache the response for S3 bucket | string | `none` | no |

main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ resource "aws_s3_bucket" "origin" {
6666
force_destroy = var.origin_force_destroy
6767
region = data.aws_region.current.name
6868

69+
dynamic "server_side_encryption_configuration" {
70+
for_each = var.encryption_enabled ? ["true"] : []
71+
72+
content {
73+
rule {
74+
apply_server_side_encryption_by_default {
75+
sse_algorithm = "AES256"
76+
}
77+
}
78+
}
79+
}
80+
6981
cors_rule {
7082
allowed_headers = var.cors_allowed_headers
7183
allowed_methods = var.cors_allowed_methods

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,9 @@ variable "wait_for_deployment" {
332332
default = true
333333
description = "When set to 'true' the resource will wait for the distribution status to change from InProgress to Deployed"
334334
}
335+
336+
variable "encryption_enabled" {
337+
type = bool
338+
default = false
339+
description = "When set to 'true' the resource will have aes256 encryption enabled by default"
340+
}

0 commit comments

Comments
 (0)