Skip to content

Commit 7d787f3

Browse files
authored
Add additional variable enable_noncurrent_version_expiration (#90)
* Add additional variable enable_noncurrent_version_expiration to give ability to not force noncurrent files translation * Autoformat changes * Push autoformat changes * Add new variables to test * Fix missing property in lifecycle_rules variable
1 parent b601290 commit 7d787f3

File tree

6 files changed

+38
-28
lines changed

6 files changed

+38
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ Available targets:
273273
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
274274
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
275275
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
276-
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | A list of lifecycle rules | <pre>list(object({<br> prefix = string<br> enabled = bool<br> tags = map(string)<br><br> enable_glacier_transition = bool<br> enable_deeparchive_transition = bool<br> enable_standard_ia_transition = bool<br> enable_current_object_expiration = bool<br><br> abort_incomplete_multipart_upload_days = number<br> noncurrent_version_glacier_transition_days = number<br> noncurrent_version_deeparchive_transition_days = number<br> noncurrent_version_expiration_days = number<br><br> standard_transition_days = number<br> glacier_transition_days = number<br> deeparchive_transition_days = number<br> expiration_days = number<br> }))</pre> | <pre>[<br> {<br> "abort_incomplete_multipart_upload_days": 90,<br> "deeparchive_transition_days": 90,<br> "enable_current_object_expiration": true,<br> "enable_deeparchive_transition": false,<br> "enable_glacier_transition": true,<br> "enable_standard_ia_transition": false,<br> "enabled": false,<br> "expiration_days": 90,<br> "glacier_transition_days": 60,<br> "noncurrent_version_deeparchive_transition_days": 60,<br> "noncurrent_version_expiration_days": 90,<br> "noncurrent_version_glacier_transition_days": 30,<br> "prefix": "",<br> "standard_transition_days": 30,<br> "tags": {}<br> }<br>]</pre> | no |
276+
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | A list of lifecycle rules | <pre>list(object({<br> prefix = string<br> enabled = bool<br> tags = map(string)<br><br> enable_glacier_transition = bool<br> enable_deeparchive_transition = bool<br> enable_standard_ia_transition = bool<br> enable_current_object_expiration = bool<br> enable_noncurrent_version_expiration = bool<br><br> abort_incomplete_multipart_upload_days = number<br> noncurrent_version_glacier_transition_days = number<br> noncurrent_version_deeparchive_transition_days = number<br> noncurrent_version_expiration_days = number<br><br> standard_transition_days = number<br> glacier_transition_days = number<br> deeparchive_transition_days = number<br> expiration_days = number<br> }))</pre> | <pre>[<br> {<br> "abort_incomplete_multipart_upload_days": 90,<br> "deeparchive_transition_days": 90,<br> "enable_current_object_expiration": true,<br> "enable_deeparchive_transition": false,<br> "enable_glacier_transition": true,<br> "enable_noncurrent_version_expiration": true,<br> "enable_standard_ia_transition": false,<br> "enabled": false,<br> "expiration_days": 90,<br> "glacier_transition_days": 60,<br> "noncurrent_version_deeparchive_transition_days": 60,<br> "noncurrent_version_expiration_days": 90,<br> "noncurrent_version_glacier_transition_days": 30,<br> "prefix": "",<br> "standard_transition_days": 30,<br> "tags": {}<br> }<br>]</pre> | no |
277277
| <a name="input_logging"></a> [logging](#input\_logging) | Bucket access logging configuration. | <pre>object({<br> bucket_name = string<br> prefix = string<br> })</pre> | `null` | no |
278278
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
279279
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |

docs/terraform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
6565
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
6666
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
67-
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | A list of lifecycle rules | <pre>list(object({<br> prefix = string<br> enabled = bool<br> tags = map(string)<br><br> enable_glacier_transition = bool<br> enable_deeparchive_transition = bool<br> enable_standard_ia_transition = bool<br> enable_current_object_expiration = bool<br><br> abort_incomplete_multipart_upload_days = number<br> noncurrent_version_glacier_transition_days = number<br> noncurrent_version_deeparchive_transition_days = number<br> noncurrent_version_expiration_days = number<br><br> standard_transition_days = number<br> glacier_transition_days = number<br> deeparchive_transition_days = number<br> expiration_days = number<br> }))</pre> | <pre>[<br> {<br> "abort_incomplete_multipart_upload_days": 90,<br> "deeparchive_transition_days": 90,<br> "enable_current_object_expiration": true,<br> "enable_deeparchive_transition": false,<br> "enable_glacier_transition": true,<br> "enable_standard_ia_transition": false,<br> "enabled": false,<br> "expiration_days": 90,<br> "glacier_transition_days": 60,<br> "noncurrent_version_deeparchive_transition_days": 60,<br> "noncurrent_version_expiration_days": 90,<br> "noncurrent_version_glacier_transition_days": 30,<br> "prefix": "",<br> "standard_transition_days": 30,<br> "tags": {}<br> }<br>]</pre> | no |
67+
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | A list of lifecycle rules | <pre>list(object({<br> prefix = string<br> enabled = bool<br> tags = map(string)<br><br> enable_glacier_transition = bool<br> enable_deeparchive_transition = bool<br> enable_standard_ia_transition = bool<br> enable_current_object_expiration = bool<br> enable_noncurrent_version_expiration = bool<br><br> abort_incomplete_multipart_upload_days = number<br> noncurrent_version_glacier_transition_days = number<br> noncurrent_version_deeparchive_transition_days = number<br> noncurrent_version_expiration_days = number<br><br> standard_transition_days = number<br> glacier_transition_days = number<br> deeparchive_transition_days = number<br> expiration_days = number<br> }))</pre> | <pre>[<br> {<br> "abort_incomplete_multipart_upload_days": 90,<br> "deeparchive_transition_days": 90,<br> "enable_current_object_expiration": true,<br> "enable_deeparchive_transition": false,<br> "enable_glacier_transition": true,<br> "enable_noncurrent_version_expiration": true,<br> "enable_standard_ia_transition": false,<br> "enabled": false,<br> "expiration_days": 90,<br> "glacier_transition_days": 60,<br> "noncurrent_version_deeparchive_transition_days": 60,<br> "noncurrent_version_expiration_days": 90,<br> "noncurrent_version_glacier_transition_days": 30,<br> "prefix": "",<br> "standard_transition_days": 30,<br> "tags": {}<br> }<br>]</pre> | no |
6868
| <a name="input_logging"></a> [logging](#input\_logging) | Bucket access logging configuration. | <pre>object({<br> bucket_name = string<br> prefix = string<br> })</pre> | `null` | no |
6969
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
7070
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |

examples/complete/lifecycle.us-east-2.tfvars

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ lifecycle_rules = [
1414
enabled = true
1515
tags = { "temp" : "true" }
1616

17-
enable_glacier_transition = false
18-
enable_deeparchive_transition = false
19-
enable_standard_ia_transition = false
20-
enable_current_object_expiration = true
17+
enable_glacier_transition = false
18+
enable_deeparchive_transition = false
19+
enable_standard_ia_transition = false
20+
enable_current_object_expiration = true
21+
enable_noncurrent_version_expiration = true
2122

2223
abort_incomplete_multipart_upload_days = null
2324
noncurrent_version_glacier_transition_days = 0
@@ -34,10 +35,11 @@ lifecycle_rules = [
3435
enabled = true
3536
tags = {}
3637

37-
enable_glacier_transition = false
38-
enable_deeparchive_transition = false
39-
enable_standard_ia_transition = false
40-
enable_current_object_expiration = true
38+
enable_glacier_transition = false
39+
enable_deeparchive_transition = false
40+
enable_standard_ia_transition = false
41+
enable_current_object_expiration = true
42+
enable_noncurrent_version_expiration = true
4143

4244
abort_incomplete_multipart_upload_days = 1
4345
noncurrent_version_glacier_transition_days = 0

examples/complete/variables.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ variable "lifecycle_rules" {
2222
enabled = bool
2323
tags = map(string)
2424

25-
enable_glacier_transition = bool
26-
enable_deeparchive_transition = bool
27-
enable_standard_ia_transition = bool
28-
enable_current_object_expiration = bool
25+
enable_glacier_transition = bool
26+
enable_deeparchive_transition = bool
27+
enable_standard_ia_transition = bool
28+
enable_current_object_expiration = bool
29+
enable_noncurrent_version_expiration = bool
2930

3031
abort_incomplete_multipart_upload_days = number
3132
noncurrent_version_glacier_transition_days = number
@@ -42,10 +43,11 @@ variable "lifecycle_rules" {
4243
prefix = ""
4344
tags = {}
4445

45-
enable_glacier_transition = true
46-
enable_deeparchive_transition = false
47-
enable_standard_ia_transition = false
48-
enable_current_object_expiration = true
46+
enable_glacier_transition = true
47+
enable_deeparchive_transition = false
48+
enable_standard_ia_transition = false
49+
enable_current_object_expiration = true
50+
enable_noncurrent_version_expiration = true
4951

5052
abort_incomplete_multipart_upload_days = 90
5153
noncurrent_version_glacier_transition_days = 30

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ resource "aws_s3_bucket" "default" {
3636
tags = lifecycle_rule.value.tags
3737
abort_incomplete_multipart_upload_days = lifecycle_rule.value.abort_incomplete_multipart_upload_days
3838

39-
noncurrent_version_expiration {
40-
days = lifecycle_rule.value.noncurrent_version_expiration_days
39+
dynamic "noncurrent_version_expiration" {
40+
for_each = lifecycle_rule.value.enable_noncurrent_version_expiration ? [1] : []
41+
42+
content {
43+
days = lifecycle_rule.value.noncurrent_version_expiration_days
44+
}
4145
}
4246

4347
dynamic "noncurrent_version_transition" {

variables.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ variable "lifecycle_rules" {
8585
enabled = bool
8686
tags = map(string)
8787

88-
enable_glacier_transition = bool
89-
enable_deeparchive_transition = bool
90-
enable_standard_ia_transition = bool
91-
enable_current_object_expiration = bool
88+
enable_glacier_transition = bool
89+
enable_deeparchive_transition = bool
90+
enable_standard_ia_transition = bool
91+
enable_current_object_expiration = bool
92+
enable_noncurrent_version_expiration = bool
9293

9394
abort_incomplete_multipart_upload_days = number
9495
noncurrent_version_glacier_transition_days = number
@@ -105,10 +106,11 @@ variable "lifecycle_rules" {
105106
prefix = ""
106107
tags = {}
107108

108-
enable_glacier_transition = true
109-
enable_deeparchive_transition = false
110-
enable_standard_ia_transition = false
111-
enable_current_object_expiration = true
109+
enable_glacier_transition = true
110+
enable_deeparchive_transition = false
111+
enable_standard_ia_transition = false
112+
enable_current_object_expiration = true
113+
enable_noncurrent_version_expiration = true
112114

113115
abort_incomplete_multipart_upload_days = 90
114116
noncurrent_version_glacier_transition_days = 30

0 commit comments

Comments
 (0)