Skip to content

Commit

Permalink
feat: Added support to override default tags of provider in S3 object
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbabenko committed Jan 26, 2024
1 parent cff9461 commit 136f60a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ module "lambda_function" {
s3_bucket = module.s3_bucket.s3_bucket_id
s3_prefix = "lambda-builds/"

s3_object_override_default_tags = true
s3_object_tags = {
S3ObjectName = "lambda1"
Override = "true"
}

artifacts_dir = "${path.root}/.terraform/lambda-builds/"

layers = [
Expand Down
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ resource "aws_s3_object" "lambda_package" {

tags = var.s3_object_tags_only ? var.s3_object_tags : merge(var.tags, var.s3_object_tags)

dynamic "override_provider" {
for_each = var.s3_object_override_default_tags ? [true] : []

content {
default_tags {
tags = {}
}
}
}

depends_on = [null_resource.archive]
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ variable "invoke_mode" {
default = null
}

variable "s3_object_override_default_tags" {
description = "Whether to override the default_tags from provider? NB: S3 objects support a maximum of 10 tags."
type = bool
default = false
}

########
# Layer
########
Expand Down
1 change: 1 addition & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module "wrapper" {
s3_bucket = try(each.value.s3_bucket, var.defaults.s3_bucket, null)
s3_existing_package = try(each.value.s3_existing_package, var.defaults.s3_existing_package, null)
s3_kms_key_id = try(each.value.s3_kms_key_id, var.defaults.s3_kms_key_id, null)
s3_object_override_default_tags = try(each.value.s3_object_override_default_tags, var.defaults.s3_object_override_default_tags, false)
s3_object_storage_class = try(each.value.s3_object_storage_class, var.defaults.s3_object_storage_class, "ONEZONE_IA")
s3_object_tags = try(each.value.s3_object_tags, var.defaults.s3_object_tags, {})
s3_object_tags_only = try(each.value.s3_object_tags_only, var.defaults.s3_object_tags_only, false)
Expand Down

0 comments on commit 136f60a

Please sign in to comment.