Last active
March 24, 2021 08:35
-
-
Save geekzter/83495fa3ed3bb43d158e5a8a47c28f83 to your computer and use it in GitHub Desktop.
Terraform instrumentation to enable teardown
This file contains hidden or 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
| # variables.tf | |
| variable resource_suffix { | |
| description = "The suffix to put at the end of resource names created" | |
| default = "" # Empty string triggers a random suffix | |
| } | |
| variable run_id { | |
| type = string | |
| default = "" | |
| } | |
| # main.tf | |
| # Random resource suffix, this will prevent name collisions when creating resources in parallel | |
| resource random_string suffix { | |
| length = 4 | |
| upper = false | |
| lower = true | |
| number = false | |
| special = false | |
| } | |
| locals { | |
| suffix = var.resource_suffix != "" ? lower(var.resource_suffix) : random_string.suffix.result | |
| tags = map( | |
| "provisioner", "terraform", | |
| "repository", "terraform-demo", | |
| "runid", var.run_id, | |
| "workspace", terraform.workspace | |
| ) | |
| } | |
| resource azurerm_resource_group synapse { | |
| name = "terraform-demo-${terraform.workspace}-${local.suffix}" | |
| location = "westeurope" | |
| tags = local.tags | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment