diff --git a/README.md b/README.md
index e6619e30..21f2884a 100644
--- a/README.md
+++ b/README.md
@@ -846,6 +846,7 @@ No modules.
| [s3\_bucket](#input\_s3\_bucket) | S3 bucket to store artifacts | `string` | `null` | no |
| [s3\_existing\_package](#input\_s3\_existing\_package) | The S3 bucket object with keys bucket, key, version pointing to an existing zip-file to use | `map(string)` | `null` | no |
| [s3\_kms\_key\_id](#input\_s3\_kms\_key\_id) | Specifies a custom KMS key to use for S3 object encryption. | `string` | `null` | no |
+| [s3\_object\_override\_default\_tags](#input\_s3\_object\_override\_default\_tags) | Whether to override the default\_tags from provider? NB: S3 objects support a maximum of 10 tags. | `bool` | `false` | no |
| [s3\_object\_storage\_class](#input\_s3\_object\_storage\_class) | Specifies the desired Storage Class for the artifact uploaded to S3. Can be either STANDARD, REDUCED\_REDUNDANCY, ONEZONE\_IA, INTELLIGENT\_TIERING, or STANDARD\_IA. | `string` | `"ONEZONE_IA"` | no |
| [s3\_object\_tags](#input\_s3\_object\_tags) | A map of tags to assign to S3 bucket object. | `map(string)` | `{}` | no |
| [s3\_object\_tags\_only](#input\_s3\_object\_tags\_only) | Set to true to not merge tags with s3\_object\_tags. Useful to avoid breaching S3 Object 10 tag limit. | `bool` | `false` | no |
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 5773b7dd..7f16007b 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -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 = [
diff --git a/main.tf b/main.tf
index a2d045df..e9a35e75 100644
--- a/main.tf
+++ b/main.tf
@@ -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]
}
diff --git a/variables.tf b/variables.tf
index 861ce789..55816734 100644
--- a/variables.tf
+++ b/variables.tf
@@ -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
########
diff --git a/wrappers/main.tf b/wrappers/main.tf
index 8a51d37f..85b9e38c 100644
--- a/wrappers/main.tf
+++ b/wrappers/main.tf
@@ -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)