Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tags, provide override or default lifecycle_rule #463

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ If you're looking to raise an issue with this module, please create a new issue
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_access_logs"></a> [access\_logs](#input\_access\_logs) | A boolean that determines whether to have access logs | `bool` | `true` | no |
| <a name="input_access_logs_lifecycle_rule"></a> [access\_logs\_lifecycle\_rule](#input\_access\_logs\_lifecycle\_rule) | Custom lifecycle rule to override the default one | <pre>list(object({<br> id = string<br> enabled = string<br> prefix = string<br> tags = map(string)<br> transition = list(object({<br> days = number<br> storage_class = string<br> }))<br> expiration = object({<br> days = number<br> })<br> noncurrent_version_transition = list(object({<br> days = number<br> storage_class = string<br> }))<br> noncurrent_version_expiration = object({<br> days = number<br> })<br> }))</pre> | <pre>[<br> {<br> "enabled": "Enabled",<br> "expiration": {<br> "days": 730<br> },<br> "id": "main",<br> "noncurrent_version_expiration": {<br> "days": 730<br> },<br> "noncurrent_version_transition": [<br> {<br> "days": 90,<br> "storage_class": "STANDARD_IA"<br> },<br> {<br> "days": 365,<br> "storage_class": "GLACIER"<br> }<br> ],<br> "prefix": "",<br> "tags": {<br> "autoclean": "true",<br> "rule": "log"<br> },<br> "transition": [<br> {<br> "days": 90,<br> "storage_class": "STANDARD_IA"<br> },<br> {<br> "days": 365,<br> "storage_class": "GLACIER"<br> }<br> ]<br> }<br>]</pre> | no |
| <a name="input_account_number"></a> [account\_number](#input\_account\_number) | Account number of current environment | `string` | n/a | yes |
| <a name="input_application_name"></a> [application\_name](#input\_application\_name) | Name of application | `string` | n/a | yes |
| <a name="input_dns_record_client_routing_policy"></a> [dns\_record\_client\_routing\_policy](#input\_dns\_record\_client\_routing\_policy) | (optional) Indicates how traffic is distributed among network load balancer Availability Zones only. Possible values are any\_availability\_zone (client DNS queries are resolved among healthy LB IP addresses across all LB Availability Zones), partial\_availability\_zone\_affinity (85 percent of client DNS queries will favor load balancer IP addresses in their own Availability Zone, while the remaining queries resolve to any healthy zone) and availability\_zone\_affinity (Client DNS queries will favor load balancer IP address in their own Availability Zone). | `string` | `"any_availability_zone"` | no |
Expand Down
48 changes: 7 additions & 41 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,14 @@ module "s3-bucket" {
versioning_enabled = var.s3_versioning
force_destroy = var.force_destroy_bucket
sse_algorithm = var.load_balancer_type == "network" ? "AES256" : "aws:kms"
lifecycle_rule = [
{
id = "main"
enabled = "Enabled"
prefix = ""

tags = {
rule = "log"
autoclean = "true"
}

transition = [
{
days = 90
storage_class = "STANDARD_IA"
}, {
days = 365
storage_class = "GLACIER"
}
]

expiration = {
days = 730
}

noncurrent_version_transition = [
{
days = 90
storage_class = "STANDARD_IA"
}, {
days = 365
storage_class = "GLACIER"
}
]
lifecycle_rule = var.access_logs_lifecycle_rule

noncurrent_version_expiration = {
days = 730
}
}
]

tags = var.tags
tags = merge(
var.tags,
{
backup = false
},
)
}

data "aws_iam_policy_document" "bucket_policy" {
Expand Down
66 changes: 66 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,69 @@ variable "dns_record_client_routing_policy" {
description = "(optional) Indicates how traffic is distributed among network load balancer Availability Zones only. Possible values are any_availability_zone (client DNS queries are resolved among healthy LB IP addresses across all LB Availability Zones), partial_availability_zone_affinity (85 percent of client DNS queries will favor load balancer IP addresses in their own Availability Zone, while the remaining queries resolve to any healthy zone) and availability_zone_affinity (Client DNS queries will favor load balancer IP address in their own Availability Zone)."
default = "any_availability_zone"
}

variable "access_logs_lifecycle_rule" {
description = "Custom lifecycle rule to override the default one"
type = list(object({
id = string
enabled = string
prefix = string
tags = map(string)
transition = list(object({
days = number
storage_class = string
}))
expiration = object({
days = number
})
noncurrent_version_transition = list(object({
days = number
storage_class = string
}))
noncurrent_version_expiration = object({
days = number
})
}))
default = [
{
id = "main"
enabled = "Enabled"
prefix = ""

tags = {
rule = "log"
autoclean = "true"
}

transition = [
{
days = 90
storage_class = "STANDARD_IA"
},
{
days = 365
storage_class = "GLACIER"
}
]

expiration = {
days = 730
}

noncurrent_version_transition = [
{
days = 90
storage_class = "STANDARD_IA"
},
{
days = 365
storage_class = "GLACIER"
}
]

noncurrent_version_expiration = {
days = 730
}
}
]
}
Loading