Skip to content

Commit f0cdf3e

Browse files
authored
feat: make glacier transition rules optional (#293)
BREAKING CHANGE: this change disables glacier transition rules by default since transitioning small objects is officially not recommended. it can be enabled by setting `var.audit_log_lifecycle_glacier_transition_days` to a positive number. https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html
1 parent a94ba14 commit f0cdf3e

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ This module is composed of several submodules and each of which can be used inde
145145
| <a name="input_audit_log_bucket_custom_policy_json"></a> [audit\_log\_bucket\_custom\_policy\_json](#input\_audit\_log\_bucket\_custom\_policy\_json) | Override policy for the audit log bucket. Allows addition of extra policies. | `string` | no |
146146
| <a name="input_audit_log_bucket_force_destroy"></a> [audit\_log\_bucket\_force\_destroy](#input\_audit\_log\_bucket\_force\_destroy) | A boolean that indicates all objects should be deleted from the audit log bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | no |
147147
| <a name="input_audit_log_bucket_key_enabled"></a> [audit\_log\_bucket\_key\_enabled](#input\_audit\_log\_bucket\_key\_enabled) | Whether or not to use Amazon S3 Bucket Keys for encrypting the audit log bucket. | `bool` | no |
148-
| <a name="input_audit_log_lifecycle_glacier_transition_days"></a> [audit\_log\_lifecycle\_glacier\_transition\_days](#input\_audit\_log\_lifecycle\_glacier\_transition\_days) | The number of days after log creation when the log file is archived into Glacier. | `number` | no |
148+
| <a name="input_audit_log_lifecycle_glacier_transition_days"></a> [audit\_log\_lifecycle\_glacier\_transition\_days](#input\_audit\_log\_lifecycle\_glacier\_transition\_days) | The number of days after log creation when the log file is archived into Glacier. Setting to zero disables the transition. | `number` | no |
149149
| <a name="input_aws_config_changes_enabled"></a> [aws\_config\_changes\_enabled](#input\_aws\_config\_changes\_enabled) | The boolean flag whether the aws\_config\_changes alarm is enabled or not. No resources are created when set to false. | `bool` | no |
150150
| <a name="input_cloudtrail_baseline_enabled"></a> [cloudtrail\_baseline\_enabled](#input\_cloudtrail\_baseline\_enabled) | Boolean whether cloudtrail-baseline is enabled. | `bool` | no |
151151
| <a name="input_cloudtrail_cfg_changes_enabled"></a> [cloudtrail\_cfg\_changes\_enabled](#input\_cloudtrail\_cfg\_changes\_enabled) | The boolean flag whether the cloudtrail\_cfg\_changes alarm is enabled or not. No resources are created when set to false. | `bool` | no |

modules/secure-bucket/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Creates a S3 bucket with access logging enabled.
2424
| <a name="input_log_bucket_name"></a> [log\_bucket\_name](#input\_log\_bucket\_name) | The name of the S3 bucket to store access logs to the main bucket. | `string` | yes |
2525
| <a name="input_bucket_key_enabled"></a> [bucket\_key\_enabled](#input\_bucket\_key\_enabled) | Whether or not to use Amazon S3 Bucket Keys for this bucket. | `bool` | no |
2626
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. | `bool` | no |
27-
| <a name="input_lifecycle_glacier_transition_days"></a> [lifecycle\_glacier\_transition\_days](#input\_lifecycle\_glacier\_transition\_days) | The number of days after object creation when the object is archived into Glacier. | `number` | no |
27+
| <a name="input_lifecycle_glacier_transition_days"></a> [lifecycle\_glacier\_transition\_days](#input\_lifecycle\_glacier\_transition\_days) | The number of days after object creation when the object is archived into Glacier. Setting to zero disables the transition. | `number` | no |
2828
| <a name="input_tags"></a> [tags](#input\_tags) | Specifies object tags key and value. This applies to all resources created by this module. | `map(string)` | no |
2929

3030
## Outputs

modules/secure-bucket/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "access_log" {
4141
}
4242

4343
resource "aws_s3_bucket_lifecycle_configuration" "access_log" {
44+
count = var.lifecycle_glacier_transition_days > 0 ? 1 : 0
45+
4446
bucket = aws_s3_bucket.access_log.id
4547

4648
rule {
@@ -108,6 +110,8 @@ resource "aws_s3_bucket_logging" "content" {
108110
}
109111

110112
resource "aws_s3_bucket_lifecycle_configuration" "content" {
113+
count = var.lifecycle_glacier_transition_days > 0 ? 1 : 0
114+
111115
bucket = aws_s3_bucket.content.id
112116

113117
rule {

modules/secure-bucket/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ variable "log_bucket_name" {
99
}
1010

1111
variable "lifecycle_glacier_transition_days" {
12-
description = "The number of days after object creation when the object is archived into Glacier."
12+
description = "The number of days after object creation when the object is archived into Glacier. Setting to zero disables the transition."
1313
type = number
14-
default = 90
14+
default = 0
1515
}
1616

1717
variable "force_destroy" {

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ variable "audit_log_bucket_key_enabled" {
8686
}
8787

8888
variable "audit_log_lifecycle_glacier_transition_days" {
89-
description = "The number of days after log creation when the log file is archived into Glacier."
89+
description = "The number of days after log creation when the log file is archived into Glacier. Setting to zero disables the transition."
9090
type = number
91-
default = 90
91+
default = 0
9292
}
9393

9494
variable "audit_log_bucket_force_destroy" {

0 commit comments

Comments
 (0)