hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.68k stars 9.55k forks source link

Feature Request - New meta-parameter, terraform_tags #15878

Open palmertime opened 7 years ago

palmertime commented 7 years ago

Feature Request

I'm interested in a new meta-parameter that can be used to define generic key/value pairs. Something like generic_tags or terraform_tags. My use case is pertaining to utilizing Terraform state to provide Ansible with a dynamic inventory. The current apps that provide this functionality use Terraform resource provider specific parameters. For instance, aws_instance reference tags and vsphere_virtual_machine reference custom_configuration_parameters to define Ansible parameters. This does work, however, has a few down sides. Specifically with vSphere, changing or adding a custom_configuration_parameters will initiate a rebuild(destroy/create). This makes sense for the original intent of custom_configuration_parameters but not for these type of generic tags or parameters. aws_instance doesn't share this same issue, however, in both cases any tags or custom_configuration_parameters are pushed up to AWS and vSphere. Again, not as big of deal as initiating a rebuild but not necessary.

Terraform/Ansible dynamic inventory projects:

Another use case of terraform_tags might be to define parameters that terraform plan -target can take advantage.

Terraform Version

0.10.2

Terraform Configuration Files

terraform_tags {
  ansible_group = "vault_server"
  ansible_user = "ansibleuser"
  ansible_host = "192.168.1.100"
  terraform_target = "vault"
}
Erictsu1947 commented 5 years ago

Any update for this?

tags in meta-attribute will be useful for resource management by state, and it's will very helpful when we try to determine a resource belong to whichone, especially on a provider without tag-supported.

Erictsu1947 commented 5 years ago

I think it is make sense to add a "_meta" section in a resource block, we could put meta-attributes, just like lifecycle/tags/timeouts in this section.