Skip to content

Instantly share code, notes, and snippets.

@jungopro
Created December 3, 2019 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jungopro/64a46885c24dbaadfa21ad2e46541fda to your computer and use it in GitHub Desktop.
Save jungopro/64a46885c24dbaadfa21ad2e46541fda to your computer and use it in GitHub Desktop.
Sample terraform code I
locals {
tags = merge(var.tags, { "workspace" = "${terraform.workspace}" }) # add terraform workspace tag to any additional tags given as input
}
resource "azurerm_resource_group" "rg" {
count = var.create_resource_group ? 1 : 0 # conditional creation
name = "${terraform.workspace}-${var.resource_group_name}"
location = var.resource_group_location
tags = local.tags
}
variable "tags" {
description = "tags to apply to the resources"
default = {}
}
variable "create_resource_group" {
description = "Option to create a Azure resource group to use for VNET"
type = bool
default = true
}
variable "resource_group_name" {
description = "The name of the resource group to use for the VNET, it is used in both cases even if the resource group is created"
type = string
default = "myRG"
}
variable "resource_group_location" {
description = "Location for resource group See. https://azure.microsoft.com/en-us/global-infrastructure/locations/"
type = string
default = "West Europe"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment