Skip to content

Commit 2cd1e44

Browse files
tmeijnkayman-mk
andauthored
fix: disable outputting config.toml by default (#768)
## Description In #754 I unfortunately made a major oversight: the `local_file` doesn't persist between machines (duh 🤦🏾 ). So for example in a CI/CD pipeline the file is not present so it wants to render the whole file as new every time. This defeats the main purpose that I had intended for this feature... Also if the pipeline applies the plan, there will be a perpetual diff, even if you save the file in repository. I still think this is useful locally for debugging purposes, but therefore I propose we disable this mechanism by default. In addition, when these variables are enabled I changed the location to the Root module for easier access if you want to debug the rendered files. ## Migrations required YES/NO - Feature is quite new, if someone wants to use keep this as introduced they now need to explicitly enable it. ## Verification ```hcl output_runner_config_to_file = true output_user_data_to_file = true ``` Results: ![image](https://user-images.githubusercontent.com/17970041/227529895-864e45e0-70aa-4b23-a725-30c4cea8b955.png) --------- Co-authored-by: kayma <[email protected]> Co-authored-by: Matthias Kay <[email protected]>
1 parent 51d63e6 commit 2cd1e44

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ package*.json
2828
yarn.lock
2929

3030
builds/
31+
debug/
3132

3233
# exceptions for semantic release
3334
!.release/package*
@@ -38,7 +39,4 @@ builds/
3839

3940
# Python
4041
.mypy_cache/
41-
venv/
42-
43-
# Terraform rendered templates
44-
debug/
42+
venv/

.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

locals.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ locals {
9393
}
9494

9595
resource "local_file" "config_toml" {
96+
count = var.debug.output_runner_config_to_file ? 1 : 0
9697
content = local.template_runner_config
97-
filename = "${path.module}/debug/runner_config.toml"
98+
filename = "${path.root}/debug/${local.name_runner_agent_instance}/runner_config.toml"
9899
}
99100

100101
resource "local_file" "user_data" {
101-
count = var.show_user_data_in_plan ? 1 : 0
102-
content = nonsensitive(local.template_user_data)
103-
filename = "${path.module}/debug/user_data.sh"
102+
count = var.debug.output_runner_user_data_to_file ? 1 : 0
103+
content = local.template_user_data
104+
filename = "${path.root}/debug/${local.name_runner_agent_instance}/user_data.sh"
104105
}

variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,4 +983,29 @@ variable "show_user_data_in_plan" {
983983
description = "When enabled, shows the diff for agent configuration files in Terraform plan: `config.toml` and user data script"
984984
type = bool
985985
default = false
986+
validation {
987+
condition = !var.show_user_data_in_plan
988+
error_message = "The variable is deprecated. Please use the 'debug' variable instead."
989+
}
990+
}
991+
992+
variable "debug" {
993+
description = <<EOT
994+
Enable debug settings for development
995+
996+
output_runner_config_to_file: When enabled, outputs the rendered config.toml file in the root module. This can
997+
then also be used by Terraform to show changes in plan. Note that enabling this can
998+
potentially expose sensitive information.
999+
output_user_data_to_file: When enabled, outputs the rendered userdata.sh file in the root module. This can then
1000+
also be used by Terraform to show changes in plan. Note that enabling this can
1001+
potentially expose sensitive information.
1002+
EOT
1003+
type = object({
1004+
output_runner_config_to_file = bool
1005+
output_runner_user_data_to_file = bool
1006+
})
1007+
default = {
1008+
output_runner_config_to_file = false
1009+
output_runner_user_data_to_file = false
1010+
}
9861011
}

0 commit comments

Comments
 (0)