Skip to content

Commit

Permalink
terraform, aws: support specifying bucket specific tags
Browse files Browse the repository at this point in the history
The intent is to allow 2i2c:hub-name to be specified. I saw no option
to easily and robustly add the 2i2c:hub-name tag automatically by using
other config or variables. The `hub_cloud_permissions` variable included
details about hub name, but I don't think we could be certain all
buckets would be tied to a hub name through that, so it seemed
problematic to try to use that information. With that in mind, I settled
for explicitly configuring any tags.
  • Loading branch information
consideRatio committed Jul 30, 2024
1 parent affa5c3 commit d2cbfb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion terraform/aws/buckets.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_s3_bucket" "user_buckets" {
for_each = var.user_buckets
bucket = lower("${var.cluster_name}-${each.key}")
tags = var.tags
tags = merge(var.tags, each.value.tags)
}

resource "aws_s3_bucket_lifecycle_configuration" "user_bucket_expiry" {
Expand Down
4 changes: 3 additions & 1 deletion terraform/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ variable "user_buckets" {
type = map(
object({
delete_after : optional(number, null),
archival_storageclass_after : optional(number, null)
archival_storageclass_after : optional(number, null),
tags : optional(map(string), {}),
})
)
default = {}
Expand All @@ -40,6 +41,7 @@ variable "user_buckets" {
2. `archival_storageclass_after` - number of days after *creation* an
object in this bucket will be automatically transitioned to a cheaper,
slower storageclass for cost savings. Set to null to not transition.
3. `tags` - bucket specific tags to be merged into the general tags variable.
EOT
}

Expand Down

0 comments on commit d2cbfb6

Please sign in to comment.