Skip to content

Commit f9cf370

Browse files
authored
Merge pull request #362 from lonegunmanb/yor-tag
Add tracing tag toggle variables
2 parents 1251e44 + feea327 commit f9cf370

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,60 @@ provider "kubernetes" {
3838

3939
There're some examples in the examples folder. You can execute `terraform apply` command in `examples`'s sub folder to try the module. These examples are tested against every PR with the [E2E Test](#Pre-Commit--Pr-Check--Test).
4040

41+
## Enable or disable tracing tags
42+
43+
We're using [BridgeCrew Yor](https://github.com/bridgecrewio/yor) and [yorbox](https://github.com/lonegunmanb/yorbox) to help manage tags consistently across infrastructure as code (IaC) frameworks. In this module you might see tags like:
44+
45+
```hcl
46+
resource "azurerm_resource_group" "rg" {
47+
location = "eastus"
48+
name = random_pet.name
49+
tags = merge(var.tags, (/*<box>*/ (var.tracing_tags_enabled ? { for k, v in /*</box>*/ {
50+
avm_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
51+
avm_git_file = "main.tf"
52+
avm_git_last_modified_at = "2023-05-05 08:57:54"
53+
avm_git_org = "lonegunmanb"
54+
avm_git_repo = "terraform-yor-tag-test-module"
55+
avm_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
56+
} /*<box>*/ : replace(k, "avm_", var.tracing_tags_prefix) => v } : {}) /*</box>*/))
57+
}
58+
```
59+
60+
To enable tracing tags, set the variable to true:
61+
62+
```hcl
63+
module "example" {
64+
source = "{module_source}"
65+
...
66+
tracing_tags_enabled = true
67+
}
68+
```
69+
70+
The `tracing_tags_enabled` is default to `false`.
71+
72+
To customize the prefix for your tracing tags, set the `tracing_tags_prefix` variable value in your Terraform configuration:
73+
74+
```hcl
75+
module "example" {
76+
source = "{module_source}"
77+
...
78+
tracing_tags_prefix = "custom_prefix_"
79+
}
80+
```
81+
82+
The actual applied tags would be:
83+
84+
```text
85+
{
86+
custom_prefix_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
87+
custom_prefix_git_file = "main.tf"
88+
custom_prefix_git_last_modified_at = "2023-05-05 08:57:54"
89+
custom_prefix_git_org = "lonegunmanb"
90+
custom_prefix_git_repo = "terraform-yor-tag-test-module"
91+
custom_prefix_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
92+
}
93+
```
94+
4195
## Pre-Commit & Pr-Check & Test
4296

4397
### Configurations

variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,19 @@ variable "workload_identity_enabled" {
11321132
default = false
11331133
description = "Enable or Disable Workload Identity. Defaults to false."
11341134
}
1135+
1136+
# tflint-ignore: terraform_unused_declarations
1137+
variable "tracing_tags_enabled" {
1138+
type = bool
1139+
description = "Whether enable tracing tags that generated by BridgeCrew Yor."
1140+
default = false
1141+
nullable = false
1142+
}
1143+
1144+
# tflint-ignore: terraform_unused_declarations
1145+
variable "tracing_tags_prefix" {
1146+
type = string
1147+
description = "Default prefix for generated tracing tags"
1148+
default = "avm_"
1149+
nullable = false
1150+
}

0 commit comments

Comments
 (0)