From acc8a2d0d4d77855fca772697ebc93d4f64a2853 Mon Sep 17 00:00:00 2001 From: Zachary Hill Date: Tue, 2 Apr 2024 16:42:34 -0600 Subject: [PATCH] updated each lifecycle_rule argument to have a default value of [] (#57) * updated each lifecycle_rule argument to have a default value of [] * Continuous Integration - terraform fmt and terraform-docs * whitespace * converted to empty objects instead of empty lists * Continuous Integration - terraform fmt and terraform-docs * testing different default types * Continuous Integration - terraform fmt and terraform-docs * commented out the breaking type constraints * added issue link * Continuous Integration - terraform fmt and terraform-docs * comment --------- Co-authored-by: zachreborn --- modules/aws/s3/bucket/README.md | 6 +-- modules/aws/s3/bucket/variables.tf | 66 ++++++++++++------------ modules/aws/transfer_family/README.md | 2 +- modules/aws/transfer_family/variables.tf | 66 ++++++++++++------------ 4 files changed, 72 insertions(+), 68 deletions(-) diff --git a/modules/aws/s3/bucket/README.md b/modules/aws/s3/bucket/README.md index c7b7ad45..fbc34824 100644 --- a/modules/aws/s3/bucket/README.md +++ b/modules/aws/s3/bucket/README.md @@ -77,7 +77,7 @@ module "bucket" { ``` ### Lifecycle Rules Example -This example creates a bucket with multiple lifecycle rules configured to transition objects to Standard-IA after 30 days, Glacier after 60 days, and expire objects after 90 days. +This example creates a bucket with multiple lifecycle rules configured to transition objects to Standard-IA after 30 days, Glacier after 60 days, and expire objects after 90 days. ``` module "logging_bucket" { source = "github.com/zachreborn/terraform-modules//modules/aws/s3/bucket" @@ -234,7 +234,7 @@ module "app_bucket" { ``` ### Intelligent Tiering Filter Example -This example makes use of a simple S3 bucket with intelligent tiering enabled. The intelligent tiering configuration will eventually end up with objects in the DEEP_ARCHIVE_ACCESS glacier tier after 120 days. Objects with the prefix 'test/' and tagged with 'project' = 'app' will utilize this intelligent tiering configuration. +This example makes use of a simple S3 bucket with intelligent tiering enabled. The intelligent tiering configuration will eventually end up with objects in the DEEP_ARCHIVE_ACCESS glacier tier after 120 days. Objects with the prefix 'test/' and tagged with 'project' = 'app' will utilize this intelligent tiering configuration. ``` module "app_bucket" { source = "github.com/zachreborn/terraform-modules//modules/aws/s3/bucket" @@ -381,7 +381,7 @@ No modules. | [key\_name\_prefix](#input\_key\_name\_prefix) | (Optional) Creates an unique alias beginning with the specified prefix. The name must start with the word alias followed by a forward slash (alias/). | `string` | `"alias/s3_key_"` | no | | [key\_policy](#input\_key\_policy) | (Optional) A valid policy JSON document. Although this is a key policy, not an IAM policy, an aws\_iam\_policy\_document, in the form that designates a principal, can be used. For more information about building policy documents with Terraform, see the AWS IAM Policy Document Guide. | `string` | `""` | no | | [key\_usage](#input\_key\_usage) | (Optional) Specifies the intended use of the key. Defaults to ENCRYPT\_DECRYPT, and only symmetric encryption and decryption are supported. | `string` | `"ENCRYPT_DECRYPT"` | no | -| [lifecycle\_rules](#input\_lifecycle\_rules) | (Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration. |
list(object({
id = string
status = string
abort_incomplete_multipart_upload = optional(object({
days_after_initiation = number
}))
expiration = optional(object({
date = optional(string)
days = optional(number)
expired_object_delete_marker = optional(bool)
}))
filter = optional(object({
object_size_greater_than = optional(number)
object_size_less_than = optional(number)
prefix = optional(string)
tag = optional(map(string))
}))
noncurrent_version_expiration = optional(object({
newer_noncurrent_versions = optional(number)
noncurrent_days = optional(number)
}))
noncurrent_version_transitions = optional(list(object({
newer_noncurrent_versions = optional(number)
noncurrent_days = optional(number)
storage_class = optional(string)
})))
transition = optional(list(object({
date = optional(string)
days = optional(number)
storage_class = optional(string)
})), [])
}))
| `null` | no | +| [lifecycle\_rules](#input\_lifecycle\_rules) | (Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration. | `any` | `null` | no | | [logging\_target\_bucket](#input\_logging\_target\_bucket) | (Optional) The name of the bucket that will receive the logs. Required if logging of the S3 bucket is set to true. | `string` | `null` | no | | [logging\_target\_prefix](#input\_logging\_target\_prefix) | (Optional) The prefix that is prepended to all log object keys. If not set, the logs are stored in the root of the bucket. | `string` | `"log/"` | no | | [mfa\_delete](#input\_mfa\_delete) | (Optional) Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values: Enabled or Disabled. | `string` | `"Disabled"` | no | diff --git a/modules/aws/s3/bucket/variables.tf b/modules/aws/s3/bucket/variables.tf index c2912245..0b90208b 100644 --- a/modules/aws/s3/bucket/variables.tf +++ b/modules/aws/s3/bucket/variables.tf @@ -179,38 +179,40 @@ variable "intelligent_tiering_days" { variable "lifecycle_rules" { description = "(Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration." - type = list(object({ - id = string - status = string - abort_incomplete_multipart_upload = optional(object({ - days_after_initiation = number - })) - expiration = optional(object({ - date = optional(string) - days = optional(number) - expired_object_delete_marker = optional(bool) - })) - filter = optional(object({ - object_size_greater_than = optional(number) - object_size_less_than = optional(number) - prefix = optional(string) - tag = optional(map(string)) - })) - noncurrent_version_expiration = optional(object({ - newer_noncurrent_versions = optional(number) - noncurrent_days = optional(number) - })) - noncurrent_version_transitions = optional(list(object({ - newer_noncurrent_versions = optional(number) - noncurrent_days = optional(number) - storage_class = optional(string) - }))) - transition = optional(list(object({ - date = optional(string) - days = optional(number) - storage_class = optional(string) - })), []) - })) + type = any + # Commenting out as this is causing a bug where expiration is always being set to 0 days. https://github.com/zachreborn/terraform-modules/issues/60 + # type = list(object({ + # id = string + # status = string + # abort_incomplete_multipart_upload = optional(object({ + # days_after_initiation = number + # })) + # expiration = optional(object({ + # date = optional(string) + # days = optional(number) + # expired_object_delete_marker = optional(bool) + # }), {}) + # filter = optional(object({ + # object_size_greater_than = optional(number) + # object_size_less_than = optional(number) + # prefix = optional(string) + # tag = optional(map(string)) + # })) + # noncurrent_version_expiration = optional(object({ + # newer_noncurrent_versions = optional(number) + # noncurrent_days = optional(number) + # })) + # noncurrent_version_transitions = optional(list(object({ + # newer_noncurrent_versions = optional(number) + # noncurrent_days = optional(number) + # storage_class = optional(string) + # })), []) + # transition = optional(list(object({ + # date = optional(string) + # days = optional(number) + # storage_class = optional(string) + # })), []) + # })) default = null } diff --git a/modules/aws/transfer_family/README.md b/modules/aws/transfer_family/README.md index 643c9f76..646ef3f3 100755 --- a/modules/aws/transfer_family/README.md +++ b/modules/aws/transfer_family/README.md @@ -135,7 +135,7 @@ _For more examples, please refer to the [Documentation](https://github.com/zachr | [host\_key](#input\_host\_key) | (Optional) The RSA, ECDSA, or ED25519 private key. This must be created ahead of time. | `string` | `null` | no | | [identity\_provider\_type](#input\_identity\_provider\_type) | (Optional) The mode of authentication enabled for this service. Valid values are SERVICE\_MANAGED or API\_GATEWAY | `string` | `"SERVICE_MANAGED"` | no | | [invocation\_role](#input\_invocation\_role) | (Optional) The ARN of the IAM role that controls your authentication with an identity provider\_type through API\_GATEWAY. | `string` | `null` | no | -| [lifecycle\_rules](#input\_lifecycle\_rules) | (Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration. |
list(object({
id = string
status = string
abort_incomplete_multipart_upload = optional(object({
days_after_initiation = number
}))
expiration = optional(object({
date = optional(string)
days = optional(number)
expired_object_delete_marker = optional(bool)
}))
filter = optional(object({
object_size_greater_than = optional(number)
object_size_less_than = optional(number)
prefix = optional(string)
tag = optional(map(string))
}))
noncurrent_version_expiration = optional(object({
newer_noncurrent_versions = optional(number)
noncurrent_days = optional(number)
}))
noncurrent_version_transitions = optional(list(object({
newer_noncurrent_versions = optional(number)
noncurrent_days = optional(number)
storage_class = optional(string)
})))
transition = optional(list(object({
date = optional(string)
days = optional(number)
storage_class = optional(string)
})), [])
}))
| `null` | no | +| [lifecycle\_rules](#input\_lifecycle\_rules) | (Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration. | `any` | `null` | no | | [logging\_role](#input\_logging\_role) | (Optional) The ARN of the IAM role that allows the service to write your server access logs to a Amazon CloudWatch log group. | `string` | `null` | no | | [name](#input\_name) | (Required) The name of the AWS Transfer Family server used to name the resources created. | `string` | n/a | yes | | [passive\_ip](#input\_passive\_ip) | (Optional) Sets passive mode for FTP and FTPS protocols and the associated IPv4 address to associate. | `string` | `null` | no | diff --git a/modules/aws/transfer_family/variables.tf b/modules/aws/transfer_family/variables.tf index 104e160d..f86ca55a 100755 --- a/modules/aws/transfer_family/variables.tf +++ b/modules/aws/transfer_family/variables.tf @@ -178,38 +178,40 @@ variable "vpc_id" { variable "lifecycle_rules" { description = "(Optional) Configuration of object lifecycle management (LCM). Can have several rules as a list of maps where each map is the lifecycle rule configuration." - type = list(object({ - id = string - status = string - abort_incomplete_multipart_upload = optional(object({ - days_after_initiation = number - })) - expiration = optional(object({ - date = optional(string) - days = optional(number) - expired_object_delete_marker = optional(bool) - })) - filter = optional(object({ - object_size_greater_than = optional(number) - object_size_less_than = optional(number) - prefix = optional(string) - tag = optional(map(string)) - })) - noncurrent_version_expiration = optional(object({ - newer_noncurrent_versions = optional(number) - noncurrent_days = optional(number) - })) - noncurrent_version_transitions = optional(list(object({ - newer_noncurrent_versions = optional(number) - noncurrent_days = optional(number) - storage_class = optional(string) - }))) - transition = optional(list(object({ - date = optional(string) - days = optional(number) - storage_class = optional(string) - })), []) - })) + type = any + # Commenting out as this is causing a bug where expiration is always being set to 0 days. https://github.com/zachreborn/terraform-modules/issues/60 + # type = list(object({ + # id = string + # status = string + # abort_incomplete_multipart_upload = optional(object({ + # days_after_initiation = number + # }), []) + # expiration = optional(object({ + # date = optional(string) + # days = optional(number) + # expired_object_delete_marker = optional(bool) + # }), []) + # filter = optional(object({ + # object_size_greater_than = optional(number) + # object_size_less_than = optional(number) + # prefix = optional(string) + # tag = optional(map(string)) + # }), []) + # noncurrent_version_expiration = optional(object({ + # newer_noncurrent_versions = optional(number) + # noncurrent_days = optional(number) + # }), []) + # noncurrent_version_transitions = optional(list(object({ + # newer_noncurrent_versions = optional(number) + # noncurrent_days = optional(number) + # storage_class = optional(string) + # })), []) + # transition = optional(list(object({ + # date = optional(string) + # days = optional(number) + # storage_class = optional(string) + # })), []) + # })) default = null }