Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Add variable for lifecycle
Browse files Browse the repository at this point in the history
Update the incredibly useful "private_s3_bucket" module that we used
extensively until something happened and we moved away from using it.
When we want to create a bucket and user without faff it was infinitely
useful.

I believe we stopped using it due to lifecycle policies; these are
disabled by default, so unless specified, things in buckets should not
be deleted.

This commit adds a variable so we can specify the amount of days that
things should be deleted. Default is 30.
  • Loading branch information
surminus committed Oct 31, 2017
1 parent 4feba75 commit 4226063
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions modules/private_s3_bucket/main.tf
Expand Up @@ -24,6 +24,11 @@ variable "lifecycle" {
default = "false"
}

variable "days_to_keep" {
type = "string"
default = 30
}


resource "template_file" "readwrite_policy_file" {
template = "${file("${path.module}/templates/readwrite_policy.tpl")}"
Expand Down Expand Up @@ -52,16 +57,8 @@ resource "aws_s3_bucket" "bucket" {
prefix = ""
enabled = "${var.lifecycle}"

transition {
days = 30
storage_class = "STANDARD_IA"
}
transition {
days = 60
storage_class = "GLACIER"
}
expiration {
days = 90
days = "${var.days_to_keep}"
}
}
}
Expand Down

0 comments on commit 4226063

Please sign in to comment.