Terraform: standardize AWS tags
AWS tags with Terraform (Ratan Mohapatra)

Terraform: standardize AWS tags

I love problems that force me to learn something "new" to solve it!

When I started to use Terraform a week ago, one of the problems that I wanted to solve was to add unique Name tags to my AWS resources along with a set of standard tags. This is how I resolved it.

  1. Create a map in locals where I declared the tags (as per a PluralSight video lesson!).

locals {
  common_tags = {
    company      = var.company
    project      = "${var.company}-${var.project}"
    billing_code = var.billing_code
  }
}        

2. Add the Name tag in the resource

# 1.VPC
resource "aws_vpc" "security" {
  cidr_block           = var.vpc_cidr
  enable_dns_hostnames = true

  tags = merge(local.common_tags, { Name = "Security VPC" })
}        

This helped with two things.

  1. Now I see Names of resources in AWS console, not empty space when you add them without a Name tag!

Article content
Fig. 1. Importance of Name tag in AWS!

2. Normally I am lazy when I add resources in Console to add the tags! But no I just have to add them to my code as I need them. Any new new "terraform apply" only updates the deployment.

Article content
Standardize AWS tags with Terraform.

References:

Terraform docs

To view or add a comment, sign in

More articles by Ratan Mohapatra

  • My experiments in AWS centralized security

    I am somewhat uncomfortable when using infrastructure in public cloud(e.g.

    1 Comment
  • Ident.me makes life easy!

    One of my network simulation exercises is to create site-to-site VPN tunnels- IPSec and Wireguard -to cloud lab…

  • How did I recover my AWS root PW and MFA

    At AWS account requires a valid email that it can communicate with and a telephone number to be used for emergency…

  • Apache Guacamole - a missing piece in my labs!

    Last weekend I was playing in my lab, which was behind a firewall and realized that I'd have to create a number of port…

    1 Comment
  • A puzzle of Windows wireless network connectivity

    When I started my career in IT, the most common advice for problem solving I got was "search in Google..

  • AWS NAT Gateway to the rescue!

    NAT gateway in AWS is commonly used for allowing "internet access" to a private network (a network that has no route…

  • Experience vs (: Attitude & Aptitude :)

    I enjoy job interviews! Sure, there could be an opportunity for moving to new environment where I can utilize my skills…

  • Simplifying AWS access- SSO by Identity federation (Azure AD)

    AWS best practice recommends a multi-account architecture where the accounts are managed from a management account…

  • Simplifying AWS Accounts management

    AWS recommends [1] creating accounts specific to a project. An obvious challenge in that case is managing multiple…

  • Transitive Routing with WireGuard VPN

    brew install wireguard-tools wg genkey | tee privatekey | wg pubkey > publickey wg genpsk > client.psk Some useful…

Insights from the community

Others also viewed

Explore topics