Created
December 3, 2019 18:06
-
-
Save jungopro/64a46885c24dbaadfa21ad2e46541fda to your computer and use it in GitHub Desktop.
Sample terraform code I
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
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