Propagating Tags from provider level down to all resources using Terraform Template

Identifying the public cloud resources and ownership is the first step in satisfying asset management.

Organizations are using Terraform to manage their Infrastructure as a code (IaaC). Meaning the whole cloud infrastructure can be defined in the Terraform template (i.e., ec2 instance, type, what image, EBSvolume, encryption, subnet, elastic IP address, etc, etc). Terraform plan command lets you see all the new additions, removal, and modification to the infrastructure before applying them. Terraform lets you define resources within config files such as variables, resources, and modules. Overall, it's the best-in-class tool that allows infrastructure to be built, modified, and to track changes with ease.

default tag at the provider level

Finally, Terraform allows you to define the tag at the provider level — this is AWESOME!

Important notes-

  1. You need Terraform version 0.12 or later.
  2. You must have Terraform AWS Provider version 3.38.0 or later.
  3. Any tags defined at the provider level are inherited by dependent modules.
  4. Propagation of tag is available for all Terraform AWS Provider resources that currently support tags .
  5. Tags at the resource level take priority/precedence over those defined at the provider level.
  6. The only exception to this rule is one resource — Auto Scaling Group.
  7. Don’t forget to define the tag separately for Auto Scaling Group.
An approach to define the local tag and merge for ASG

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aakif Shaikh, CISSP, CEH, CHFI, CISA, GWAPT

Aakif Shaikh, CISSP, CEH, CHFI, CISA, GWAPT

Over 18 years of experience in a wide variety of technical domains within information security including information assurance, compliance, and risk management.