Skip to content

Commit

Permalink
Add additional variable enable_noncurrent_version_expiration (#90)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wszychta authored Aug 25, 2021
1 parent b601290 commit 7d787f3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Available targets:
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
2 changes: 1 addition & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
18 changes: 10 additions & 8 deletions examples/complete/lifecycle.us-east-2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ lifecycle_rules = [
enabled = true
tags = { "temp" : "true" }

enable_glacier_transition = false
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_glacier_transition = false
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_noncurrent_version_expiration = true

abort_incomplete_multipart_upload_days = null
noncurrent_version_glacier_transition_days = 0
Expand All @@ -34,10 +35,11 @@ lifecycle_rules = [
enabled = true
tags = {}

enable_glacier_transition = false
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_glacier_transition = false
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_noncurrent_version_expiration = true

abort_incomplete_multipart_upload_days = 1
noncurrent_version_glacier_transition_days = 0
Expand Down
18 changes: 10 additions & 8 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ variable "lifecycle_rules" {
enabled = bool
tags = map(string)

enable_glacier_transition = bool
enable_deeparchive_transition = bool
enable_standard_ia_transition = bool
enable_current_object_expiration = bool
enable_glacier_transition = bool
enable_deeparchive_transition = bool
enable_standard_ia_transition = bool
enable_current_object_expiration = bool
enable_noncurrent_version_expiration = bool

abort_incomplete_multipart_upload_days = number
noncurrent_version_glacier_transition_days = number
Expand All @@ -42,10 +43,11 @@ variable "lifecycle_rules" {
prefix = ""
tags = {}

enable_glacier_transition = true
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_glacier_transition = true
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_noncurrent_version_expiration = true

abort_incomplete_multipart_upload_days = 90
noncurrent_version_glacier_transition_days = 30
Expand Down
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ resource "aws_s3_bucket" "default" {
tags = lifecycle_rule.value.tags
abort_incomplete_multipart_upload_days = lifecycle_rule.value.abort_incomplete_multipart_upload_days

noncurrent_version_expiration {
days = lifecycle_rule.value.noncurrent_version_expiration_days
dynamic "noncurrent_version_expiration" {
for_each = lifecycle_rule.value.enable_noncurrent_version_expiration ? [1] : []

content {
days = lifecycle_rule.value.noncurrent_version_expiration_days
}
}

dynamic "noncurrent_version_transition" {
Expand Down
18 changes: 10 additions & 8 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ variable "lifecycle_rules" {
enabled = bool
tags = map(string)

enable_glacier_transition = bool
enable_deeparchive_transition = bool
enable_standard_ia_transition = bool
enable_current_object_expiration = bool
enable_glacier_transition = bool
enable_deeparchive_transition = bool
enable_standard_ia_transition = bool
enable_current_object_expiration = bool
enable_noncurrent_version_expiration = bool

abort_incomplete_multipart_upload_days = number
noncurrent_version_glacier_transition_days = number
Expand All @@ -105,10 +106,11 @@ variable "lifecycle_rules" {
prefix = ""
tags = {}

enable_glacier_transition = true
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_glacier_transition = true
enable_deeparchive_transition = false
enable_standard_ia_transition = false
enable_current_object_expiration = true
enable_noncurrent_version_expiration = true

abort_incomplete_multipart_upload_days = 90
noncurrent_version_glacier_transition_days = 30
Expand Down

0 comments on commit 7d787f3

Please sign in to comment.