Skip to content

claranet/terraform-claranet-default-tags

Repository files navigation

Claranet Terraform default tags module

Claranet's Terraform default tags module is here to help you deploy Claranet's tagging policy on your projects.

Usage

AWS

On AWS you can use module output to set the default_tags parameter of the AWS provider:

module "default_tags" {
  source = "github.com/claranet/claranet-terraform-default-tags"

  environment              = var.environment
}

provider "aws" {
  region     = var.aws_region
  access_key = var.aws_access_key
  secret_key = var.aws_secret_key
  token      = var.aws_token

  default_tags {
    tags = module.default_tags.default_tags
  }
}

You can add any tag you want by merging the output with additional tags:

provider "aws" {
  region     = var.aws_region
  access_key = var.aws_access_key
  secret_key = var.aws_secret_key
  token      = var.aws_token

  default_tags {
    tags = merge(
      module.default_tags.default_tags,
      {
        environment = var.environment
      }
    )
  }
}

Azure

On Azure using Claranet modules you can use the extra_tags parameter:

module "default_tags" {
  source = "github.com/claranet/claranet-terraform-default-tags"

  environment = var.environment
}

module "azure_region" {
  source  = "claranet/regions/azurerm"

  azure_region = var.azure_region
}

module "rg" {
  source  = "claranet/rg/azurerm"

  location    = module.azure_region.location
  client_name = var.client_name
  environment = var.environment
  stack       = var.stack

  extra_tags = module.default_tags.default_tags
}

Requirements

Name Version
terraform >= 1
git >= 2023.1.20

Providers

Name Version
git >= 2023.1.20

Modules

No modules.

Resources

Name Type
git_remotes.current data source

Inputs

Name Description Type Default Required
application_stack_name Application stack name string null no
custom_iac_git_url Optional custom iac git url string null no
deployed_by How the resources are managed string "terraform" no
environment What is the environment of the resources string n/a yes
git_remote_name Git remote name string "origin" no
managed_by Who is managing the resources string "claranet" no
owner Who is owner of the resources string null no
stack Terraform stack name string null no
supervised_by Who is supervising the resources string "claranet" no
synapps_project_id Project ID as defined in Claranet SynApps CMDB to set the claranet_project_id tag string null no
synapps_status Resource status as defined in Claranet SynApps CMDB to override the status field string null no

Outputs

Name Description
default_tags Generated default tags.

Development

To automatically install required plugins and versions with asdf use:

make dev-install

asdf

asdf allows to easily manage tools version per project. See documentation for installation instructions.

Versions are described in the .tool-versions file. If you already have the required plugins installed, simply run:

asdf install

pre-commit

To enable pre-commit hooks, run:

pre-commit install

terraform-docs

To update Terraform documentation in README.md run:

make docs

tflint and tfsec

To manually run linters run:

make lint