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

[feature] Allow conditionally disable the encryption configuration #25

Closed
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
2 changes: 1 addition & 1 deletion .config/.terraform-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ content: |-
{{ include "examples/regional-deployment/example2.tfnot" }}
```
---
---
{{ .Requirements }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ module "iam_role_s3" {
|------|-------------|------|---------|:--------:|
| <a name="input_days_to_object_expiration"></a> [days\_to\_object\_expiration](#input\_days\_to\_object\_expiration) | Number of days before expiring data completely | `string` | `"2557"` | no |
| <a name="input_enable_centralized_logging"></a> [enable\_centralized\_logging](#input\_enable\_centralized\_logging) | Enable support for centralized logging to a centralized logging account | `bool` | `false` | no |
| <a name="input_enable_encryption"></a> [enable\_encryption](#input\_enable\_encryption) | Allows disable the the bucket encryption configuration | `bool` | `true` | no |
| <a name="input_enable_object_expiration"></a> [enable\_object\_expiration](#input\_enable\_object\_expiration) | Number of days before expiring data completely | `bool` | `false` | no |
| <a name="input_iam_role_s3_replication_arn"></a> [iam\_role\_s3\_replication\_arn](#input\_iam\_role\_s3\_replication\_arn) | IAM Role that enable S3 Role Assumption for Centralized Logging | `string` | `""` | no |
| <a name="input_input_tags"></a> [input\_tags](#input\_input\_tags) | Map of tags to apply to resources | `map(string)` | `{}` | no |
Expand Down
6 changes: 6 additions & 0 deletions inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ variable "replication_dest_storage_class" {
description = "The storage class to send replicated objects (https://docs.aws.amazon.com/AmazonS3/latest/API/API_Transition.html#AmazonS3-Type-Transition-StorageClass)"
type = string
default = "STANDARD_IA"
}

variable "enable_encryption" {
description = "Allows disable the the bucket encryption configuration"
type = bool
default = true
}
2 changes: 2 additions & 0 deletions main.tf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jheison-rodriguez , Below is the code to create an S3 bucket we are using:

module "s3_bucket_logging" {
source = "StratusGrid/s3-bucket-logging/aws"
version = "2.1.3"
name_prefix = var.name_prefix
name_suffix = "${local.name_suffix}-${var.region}"
input_tags = merge(local.common_tags, {})
}

Could you please point out what parameter would be used in the module definition to disable encryption?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize the use of the module with the new feature will be:

module "s3_bucket_logging" {
source = "StratusGrid/s3-bucket-logging/aws"
version = "2.1.3"
name_prefix = var.name_prefix
name_suffix = "${local.name_suffix}-${var.region}"
input_tags = merge(local.common_tags, {})
enable_encryption = false
}

Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket" {

#tfsec:ignore:aws-s3-encryption-customer-key
resource "aws_s3_bucket_server_side_encryption_configuration" "bucket" {
count = var.enable_encryption == true ? 1 : 0

bucket = aws_s3_bucket.bucket.bucket

rule {
Expand Down
Loading