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

Disable retention option #24

Merged
merged 12 commits into from
May 15, 2020
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Available targets:
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no |
| enable_glacier_transition | Enables the transition to AWS Glacier which can cause unnecessary costs for huge amount of small files | bool | `true` | no |
| enable_standard_ia_transition | Enables the transition to STANDARD_IA | bool | `false` | no |
| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no |
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no |
| expiration_days | Number of days after which to expunge the objects | number | `90` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no |
| enable_glacier_transition | Enables the transition to AWS Glacier which can cause unnecessary costs for huge amount of small files | bool | `true` | no |
| enable_standard_ia_transition | Enables the transition to STANDARD_IA | bool | `false` | no |
| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no |
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no |
| expiration_days | Number of days after which to expunge the objects | number | `90` | no |
Expand Down
11 changes: 3 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@ resource "aws_s3_bucket" "default" {
}
}

transition {
days = var.standard_transition_days
storage_class = "STANDARD_IA"
}

dynamic "transition" {
for_each = var.enable_glacier_transition ? [1] : []
for_each = var.enable_glacier_transition || var.enable_standard_ia_transition ? [1] : []

content {
days = var.glacier_transition_days
storage_class = "GLACIER"
days = var.glacier_transition_days == null ? var.standard_transition_days : 30
aknysh marked this conversation as resolved.
Show resolved Hide resolved
storage_class = var.enable_glacier_transition == "GLACIER" ? "STANDARD_IA" : ""
jamengual marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ variable "enable_glacier_transition" {
description = "Enables the transition to AWS Glacier which can cause unnecessary costs for huge amount of small files"
}

variable "enable_standard_ia_transition" {
type = bool
default = false
description = "Enables the transition to STANDARD_IA"
}

variable "expiration_days" {
type = number
default = 90
Expand Down