Skip to content

Commit b13fa1b

Browse files
authored
Add tracing tag toggle variables and update readme (#27)
1 parent 3420fbb commit b13fa1b

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,22 @@ map(object({
230230

231231
Default: `{}`
232232

233+
### <a name="input_tracing_tags_enabled"></a> [tracing\_tags\_enabled](#input\_tracing\_tags\_enabled)
234+
235+
Description: Whether enable tracing tags that generated by BridgeCrew Yor.
236+
237+
Type: `string`
238+
239+
Default: `false`
240+
241+
### <a name="input_tracing_tags_prefix"></a> [tracing\_tags\_prefix](#input\_tracing\_tags\_prefix)
242+
243+
Description: Default prefix for generated tracing tags
244+
245+
Type: `string`
246+
247+
Default: `"avm_"`
248+
233249
## Resources
234250

235251
The following resources are used by this module:
@@ -267,6 +283,60 @@ Description: A curated output of the resource groups created by this module.
267283
Description: A curated output of the virtual networks created by this module.
268284

269285
<!-- markdownlint-enable -->
286+
## Enable or disable tracing tags
287+
288+
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:
289+
290+
```hcl
291+
resource "azurerm_resource_group" "rg" {
292+
location = "eastus"
293+
name = random_pet.name
294+
tags = merge(var.tags, (/*<box>*/ (var.tracing_tags_enabled ? { for k, v in /*</box>*/ {
295+
avm_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
296+
avm_git_file = "main.tf"
297+
avm_git_last_modified_at = "2023-05-05 08:57:54"
298+
avm_git_org = "lonegunmanb"
299+
avm_git_repo = "terraform-yor-tag-test-module"
300+
avm_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
301+
} /*<box>*/ : replace(k, "avm_", var.tracing_tags_prefix) => v } : {}) /*</box>*/))
302+
}
303+
```
304+
305+
To enable tracing tags, set the variable to true:
306+
307+
```hcl
308+
module "example" {
309+
source = <module_source>
310+
...
311+
tracing_tags_enabled = true
312+
}
313+
```
314+
315+
The `tracing_tags_enabled` is default to `false`.
316+
317+
To customize the prefix for your tracing tags, set the `tracing_tags_prefix` variable value in your Terraform configuration:
318+
319+
```hcl
320+
module "example" {
321+
source = <module_source>
322+
...
323+
tracing_tags_prefix = "custom_prefix_"
324+
}
325+
```
326+
327+
The actual applied tags would be:
328+
329+
```text
330+
{
331+
custom_prefix_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
332+
custom_prefix_git_file = "main.tf"
333+
custom_prefix_git_last_modified_at = "2023-05-05 08:57:54"
334+
custom_prefix_git_org = "lonegunmanb"
335+
custom_prefix_git_repo = "terraform-yor-tag-test-module"
336+
custom_prefix_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
337+
}
338+
```
339+
270340
<!-- markdownlint-disable MD041 -->
271341
## Contributing
272342
<!-- markdownlint-enable -->

_footer.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
## Enable or disable tracing tags
2+
3+
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:
4+
5+
```hcl
6+
resource "azurerm_resource_group" "rg" {
7+
location = "eastus"
8+
name = random_pet.name
9+
tags = merge(var.tags, (/*<box>*/ (var.tracing_tags_enabled ? { for k, v in /*</box>*/ {
10+
avm_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
11+
avm_git_file = "main.tf"
12+
avm_git_last_modified_at = "2023-05-05 08:57:54"
13+
avm_git_org = "lonegunmanb"
14+
avm_git_repo = "terraform-yor-tag-test-module"
15+
avm_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
16+
} /*<box>*/ : replace(k, "avm_", var.tracing_tags_prefix) => v } : {}) /*</box>*/))
17+
}
18+
```
19+
20+
To enable tracing tags, set the variable to true:
21+
22+
```hcl
23+
module "example" {
24+
source = <module_source>
25+
...
26+
tracing_tags_enabled = true
27+
}
28+
```
29+
30+
The `tracing_tags_enabled` is default to `false`.
31+
32+
To customize the prefix for your tracing tags, set the `tracing_tags_prefix` variable value in your Terraform configuration:
33+
34+
```hcl
35+
module "example" {
36+
source = <module_source>
37+
...
38+
tracing_tags_prefix = "custom_prefix_"
39+
}
40+
```
41+
42+
The actual applied tags would be:
43+
44+
```text
45+
{
46+
custom_prefix_git_commit = "3077cc6d0b70e29b6e106b3ab98cee6740c916f6"
47+
custom_prefix_git_file = "main.tf"
48+
custom_prefix_git_last_modified_at = "2023-05-05 08:57:54"
49+
custom_prefix_git_org = "lonegunmanb"
50+
custom_prefix_git_repo = "terraform-yor-tag-test-module"
51+
custom_prefix_yor_trace = "a0425718-c57d-401c-a7d5-f3d88b2551a4"
52+
}
53+
```
54+
155
<!-- markdownlint-disable MD041 -->
256
## Contributing
357
<!-- markdownlint-enable -->

variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,19 @@ DESCRIPTION
165165
error_message = "At least one hub virtual network must be defined."
166166
}
167167
}
168+
169+
# tflint-ignore: terraform_unused_declarations
170+
variable "tracing_tags_enabled" {
171+
type = bool
172+
description = "Whether enable tracing tags that generated by BridgeCrew Yor."
173+
default = false
174+
nullable = false
175+
}
176+
177+
# tflint-ignore: terraform_unused_declarations
178+
variable "tracing_tags_prefix" {
179+
type = string
180+
description = "Default prefix for generated tracing tags"
181+
default = "avm_"
182+
nullable = false
183+
}

0 commit comments

Comments
 (0)