For example, I have a parent module that creates aws_db_instance
resource,
with the tags
argument:
tags = {
Name = “test”
Service = “service1”
Environment = “development”
}
Is there any way that I can append/modify this argument from a child module?
Use case is I want to add more tags to the RDS instance without modifying the parent module.
Hi @derianpt,
Data flow in Terraform is always explicit, so there is no way for a child module to implicitly alter the content of a parent module.
The closest you can get here is to make your child module export a map of additonal tags and then explicitly merge that with the tags in your RDS instance block, so that the value is clearly defined in the configuration:
tags = merge(module.example.additional_tags, {
Name = "test"
Service = "service1"
Environment = "development"
})
1 Like
Thanks Martin. Even though this requires a one time update to the parent module, it fulfils the use case