Coder Social home page Coder Social logo

terraform-azurerm-tagging's Introduction

Azure tagging

Changelog Notice Apache V2 License TF Registry

This Terraform helper allows to merge or overwrite tags on a resource.

Global versioning rule for Claranet Azure modules

Module version Terraform version AzureRM version
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

module "myresource_tagging" {
  source  = "claranet/tagging/azurerm"
  version = "x.x.x"

  nb_resources = 2
  resource_ids = [var.myresource_id_1, var.myresource_id_2]
  behavior     = "merge" # Must be "merge" or "overwrite"

  tags = {
    "foo"        = "bar"
    "monitoring" = "true"
  }
}

Providers

Name Version
azurerm >= 1.31
null >= 2

Modules

No modules.

Resources

Name Type
null_resource.tags resource
azurerm_client_config.current data source

Inputs

Name Description Type Default Required
behavior Behavior for tags applying. Must be merge or overwrite. string "merge" no
force True to apply every time bool false no
interpreter System interpreter to use for tagging script. string "bash" no
nb_resources Number of resources to tag number n/a yes
resource_ids Id of the Azure resources to tag list(string) n/a yes
tags Tags to apply on resource map(string) n/a yes

Outputs

No outputs.

Related documentation

Microsoft Azure tagging documentation: docs.microsoft.com/fr-fr/azure/azure-resource-manager/resource-group-using-tags

terraform-azurerm-tagging's People

Contributors

bd-clara avatar bzspi avatar epopisces avatar jmapro avatar maxpoullain avatar rossifumax avatar shr3ps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azurerm-tagging's Issues

terraform - Azure add tags to existing resources

Can you please guide me what exact resource and provider to be used in terraform for all resources in azure(vms, storage, RG etc..)
I have done with Azure cli and powershell commands, but need help on terraform.

Submodule does not support PowerShell (for Windows build runners)

I would like to contribute to the repository to allow use of the tagging submodule on Windows platforms (local-exec provisioner using a PowerShell interpreter) in a way that does not impact existing use for bash implementations. Something like so:

variables.tf

# defaults to "bash" to maintain default operation

variable "interpreter" {
  description = "Indicates which shell the script should run in"
  type        = string
  default     = "bash"
  validation {
    condition     = contains(["bash", "PowerShell"], var.interpreter)
    error_message = "The value for interpreter must be either `bash` or `PowerShell`."
  }
}

tagging.tf

...
  provisioner "local-exec" {
    interpreter = var.interpreter == "PowerShell" ? ["PowerShell"] : ["/bin/bash", "-c"]
    command     = var.interpreter == "PowerShell" ? templatefile("${path.module}/script/tag.ps1.tmpl",
      {
        behavior        = var.behavior
        resource_id     = var.resource_ids[count.index]
        tags            = local.tags
        subscription_id = data.azurerm_client_config.current.subscription_id
      }
    ) : templatefile("${path.module}/script/tag.sh.tmpl",
      {
        behavior        = var.behavior
        resource_id     = var.resource_ids[count.index]
        tags            = local.tags
        subscription_id = data.azurerm_client_config.current.subscription_id
      }
    )
  }
...

tag.ps1.tmpl would then be a modified copy of the tag.sh.tmpl file with PowerShell syntax.

If that is not desirable based on the vision/intended audience of the module I'd be willing to maintain a fork of the repository. This module perfectly solves a need I have in my organization for nondestructively merging Azure resource tags, but we have Windows runners in some environments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.