Skip to content

Commit 5b5c335

Browse files
tmeijnkayman-mk
andauthoredMar 22, 2023
feat: show config.toml and user data in Terraform plan (#754)
## Description ### What Adds a new variable `show_user_data_in_plan` which is `false` by default (there could be sensitive data leaked). * Writes the rendered `config.toml` to a file * Writes the agent's user data to a file. ### Why * By writing the rendered `config.toml` to a file we get an actual diff of the `config.toml` when we change values in our Terraform plan. In addition this would help us with the refactoring work were currently doing. * Even better ability to see the impact of changes we make. ## Migrations required NO ## Verification `show_user_data_in_plan = true` ![image](https://user-images.githubusercontent.com/17970041/225928978-cd8b31b0-9fbf-4cdb-89b3-8885a4d52f99.png) Example of `config.toml` showing a diff in plan: ![image](https://user-images.githubusercontent.com/17970041/225929105-ff04ae01-39c0-40cc-adb0-5181f5a94b46.png) --------- Co-authored-by: Matthias Kay <[email protected]> Co-authored-by: kayma <[email protected]>
1 parent ac0ca54 commit 5b5c335

File tree

11 files changed

+121
-77
lines changed

11 files changed

+121
-77
lines changed
 

‎.cspell.json

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "0.2",
33
"language": "en",
44
"words": [
5+
"amazonec",
56
"amannn",
67
"anytrue",
78
"aquasecurity",
@@ -12,6 +13,8 @@
1213
"concat",
1314
"devskim",
1415
"dind",
16+
"endfor",
17+
"formatlist",
1518
"gitter",
1619
"kics",
1720
"jsonencode",
@@ -21,11 +24,13 @@
2124
"oxsecurity",
2225
"shuf",
2326
"signoff",
27+
"signum",
2428
"substr",
2529
"templatefile",
2630
"terrascan",
2731
"tfenv",
2832
"tflint",
33+
"tftpl",
2934
"tfsec",
3035
"tfvars",
3136
"tmpfs",

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ builds/
3838

3939
# Python
4040
venv/
41+
42+
# Terraform rendered templates
43+
debug/

‎examples/runner-default/.terraform.lock.hcl

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/runner-docker/.terraform.lock.hcl

+19-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/runner-multi-region/.terraform.lock.hcl

+32-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/runner-multi-region/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
}
99
local = {
1010
source = "hashicorp/local"
11-
version = "2.2.3"
11+
version = "2.4.0"
1212
}
1313
null = {
1414
source = "hashicorp/null"

‎examples/runner-pre-registered/.terraform.lock.hcl

+32-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/runner-pre-registered/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
}
99
local = {
1010
source = "hashicorp/local"
11-
version = "2.2.3"
11+
version = "2.4.0"
1212
}
1313
null = {
1414
source = "hashicorp/null"

‎locals.tf

+11
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,14 @@ locals {
9191

9292
docker_machine_adds_name_tag = signum(sum(local.docker_machine_version_test)) <= 0
9393
}
94+
95+
resource "local_file" "config_toml" {
96+
content = local.template_runner_config
97+
filename = "${path.module}/debug/runner_config.toml"
98+
}
99+
100+
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"
104+
}

0 commit comments

Comments
 (0)
Please sign in to comment.