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

feat: Allow override of the default tags override #261

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions examples/object/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,19 @@ module "s3_bucket_with_object_lock" {
object_lock_enabled = "Enabled"
}
}

module "object_with_default_tags_override" {
source = "../../modules/object"

bucket = module.s3_bucket.s3_bucket_id
key = "${random_pet.this.id}-local"
override_default_tags = true

file_source = "README.md"
# content = file("README.md")
# content_base64 = filebase64("README.md")

tags = {
Sensitive = "not-really"
}
}
9 changes: 9 additions & 0 deletions modules/object/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ resource "aws_s3_object" "this" {
lifecycle {
ignore_changes = [object_lock_retain_until_date]
}

override_provider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change it so that the override_provider block is used only if necessary (override_default_tags should be true).

Also, please keep lifecycle block as the last one.

dynamic "default_tags" {
for_each = var.override_default_tags ? [true] : []
content {
tags = {}
}
}
}
}
6 changes: 6 additions & 0 deletions modules/object/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ variable "source_hash" {
type = string
default = null
}

variable "override_default_tags" {
description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags."
type = bool
default = false
}
2 changes: 1 addition & 1 deletion modules/object/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.75"
version = ">= 5.24"
}
}
}
Loading