Created
February 8, 2024 18:19
-
-
Save dustindortch/440c5be1a2906444939afc0a693ad824 to your computer and use it in GitHub Desktop.
Terraform Best Practices: Do Not Hard Code Values - Use Locals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "location" { | |
default = "eastus" | |
description = "Azure deployment region" | |
type = string | |
} | |
variable "resource_group_name" { | |
default = "rg-eus-test-myrg" | |
description = "Resource Group name for deployment" | |
type = string | |
} | |
variable "tags" { | |
default = { | |
Environment = "test" | |
} | |
description = "Supplied Resource Group tags" | |
type = map(string) | |
} | |
locals { | |
mandatory_tags = { | |
CreatedBy = "Terraform" | |
} | |
tags = merge(var.tags, local.mandatory_tags) | |
} | |
resource "azurerm_resource_group" "rg" { | |
name = var.resource_group_name | |
location = var.location | |
tags = local.tags | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment