Default tags are not being applied
mmoreno43 opened this issue · comments
Description
Hello, I am creating an S3 bucket using the terraform module and i have noticed that during creation that the default tags are not created.
If your request is for a new feature, please use the Feature request
template.
- [ X ] ✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
Versions
-
Module version [Required]: 3.15.1
-
Terraform version: v1.5.2
-
Provider version(s): v5.8.0
Reproduction Code [Required]
main.tf
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
bucket = "somenamehere435354353165156"
versioning = {
enabled = true
}
}
providers.tf
provider "aws" {
region = "us-west-2"
access_key = "x"
secret_key = "x"
assume_role {
role_arn = "arn:aws:iam::x:role/AWSAdministratorAccess"
}
default_tags {
tags = {
"tag1" = var.tag1
"tag2" = var.tag2
"tag3" = var.tag3
"tag4" = var.tag4
}
}
}
terraform.tfvars
tag1 = "something"
tag2 = "boo"
tag3 = "foo"
tag4 = "doo"
Steps to reproduce the behavior:
- terraform init
- terraform plan
- terraform apply
Expected behavior
The expected behavior is that the default tags are applied when I create an S3 bucket.
Actual behavior
The actual behavior is that S3 buckets being created without default tags. I have other resources where default tags get applied no problem.
Terminal Output Screenshot(s)
Additional context
I cloned the repo and did some testing of my own. I found that if I added a static tag on line 33 like
tags = merge(var.tags, {"Name" = "${var.bucket}"})
Hi @mmoreno43 !
I can't reproduce it with your code, but I recommend you to double-check that var.tag1
and others are not null
. In your example, tag4
is set to null
, and as a result, it is not added to the bucket.
Please ask follow-up clarification questions on discuss.hashicorp.com and keep this repo to bugs/improvements in the module.