Skip to content

Commit

Permalink
- s3-access-logs
Browse files Browse the repository at this point in the history
  - bucket_key_enabled: default true
  - use_kms_encryptioon: default true
    may need to make default false as some services like NLB do not support the use of a CMK (use AES256 instead)
  • Loading branch information
badra001 committed Sep 21, 2023
1 parent 76275ed commit 79c6886
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,9 @@
- add enable_cloudwatch_logs with a default of true
- cloudtrail-key
- add s3.amazonaws.com

* 2.4.7 -- 2023-09-21
- s3-access-logs
- bucket_key_enabled: default true
- use_kms_encryptioon: default true
may need to make default false as some services like NLB do not support the use of a CMK (use AES256 instead)
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "2.4.6"
_module_version = "2.4.7"
}
3 changes: 3 additions & 0 deletions s3-access-logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,21 @@ No modules.
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.logs_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_regions.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/regions) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_account_alias"></a> [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no |
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no |
| <a name="input_bucket_key_enabled"></a> [bucket\_key\_enabled](#input\_bucket\_key\_enabled) | Enable or disable the use of S3 Bucket Keys (see AWS documenation at https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html). | `bool` | `true` | no |
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Logging S3 bucket name | `string` | `""` | no |
| <a name="input_bucket_name_prefix"></a> [bucket\_name\_prefix](#input\_bucket\_name\_prefix) | Logging S3 bucket prefix, prepended to the AWS account ID and region to make the bucket name. | `string` | `"inf-logs"` | no |
| <a name="input_component_tags"></a> [component\_tags](#input\_component\_tags) | Additional tags for Components (s3, kms, ddb) | `map(map(string))` | <pre>{<br> "ddb": {},<br> "kms": {},<br> "s3": {}<br>}</pre> | no |
| <a name="input_override_prefixes"></a> [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component (efs, s3, ebs, kms, role, policy, security-group). This should be used primarily for common infrastructure things | `map(string)` | `{}` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no |
| <a name="input_use_kms_encryption"></a> [use\_kms\_encryption](#input\_use\_kms\_encryption) | Enable AWS:KMS encryption (default). If false, enables SSE-S3 (AES256), needed for some AWS services access | `bool` | `true` | no |
| <a name="input_versioning_configuration"></a> [versioning\_configuration](#input\_versioning\_configuration) | S3 Versioning Configuration (Enabled, Disabled, Suspended). To disable, use Suspended if existing bucket and Disabled if new | `string` | `"Disabled"` | no |

## Outputs
Expand Down
3 changes: 2 additions & 1 deletion s3-access-logs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "logs" {
bucket = aws_s3_bucket.logs.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
sse_algorithm = var.use_kms_encryption ? "aws:kms" : "AES256"
}
bucket_key_enabled = var.bucket_key_enabled
}
}

Expand Down
12 changes: 12 additions & 0 deletions s3-access-logs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ variable "versioning_configuration" {
type = string
default = "Disabled"
}

variable "bucket_key_enabled" {
description = "Enable or disable the use of S3 Bucket Keys (see AWS documenation at https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.html)."
type = bool
default = true
}

variable "use_kms_encryption" {
description = "Enable AWS:KMS encryption (default). If false, enables SSE-S3 (AES256), needed for some AWS services access"
type = bool
default = true
}

0 comments on commit 79c6886

Please sign in to comment.