From 3b599e3fc609e6bf07d1c4b0bebc2287458f73a9 Mon Sep 17 00:00:00 2001 From: Mason Cole <117116981+bt-macole@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:16:44 -0700 Subject: [PATCH] fix: pretty print output using terraform to syntax highlight will pretty print the plan/applys. there is a bit of extra highlighting that will occur, but the readability buff to the primary area of interest seems well worth that tradeoff. with `terraform` ```terraform time=2023-09-11T15:04:18Z level=info msg=The stack at /github/workspace/dependencies-project will be processed in the following order for command plan: Group 1 - Module /github/workspace/dependencies-project/module1 - Module /github/workspace/dependencies-project/module2 Group 2 - Module /github/workspace/dependencies-project/app Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/local... Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/local... - Installing hashicorp/local v2.4.0... - Installing hashicorp/local v2.4.0... - Installed hashicorp/local v2.4.0 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! - Installed hashicorp/local v2.4.0 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # local_file.f1 will be created + resource "local_file" "f1" { + content = "file" + content_base64sha256 = (known after apply) + content_base64sha512 = (known after apply) + content_md5 = (known after apply) + content_sha1 = (known after apply) + content_sha256 = (known after apply) + content_sha512 = (known after apply) + directory_permission = "0777" + file_permission = "0777" + filename = "./file.txt" + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + file = "./file.txt" Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # local_file.f1 will be created + resource "local_file" "f1" { + content = "file" + content_base64sha256 = (known after apply) + content_base64sha512 = (known after apply) + content_md5 = (known after apply) + content_sha1 = (known after apply) + content_sha256 = (known after apply) + content_sha512 = (known after apply) + directory_permission = "0777" + file_permission = "0777" + filename = "./file.txt" + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + file = "./file.txt" Initializing the backend... Initializing provider plugins... Terraform has been successfully initialized! No changes. Your infrastructure matches the configuration. Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed. ``` now: ``` time=2023-09-11T15:04:18Z level=info msg=The stack at /github/workspace/dependencies-project will be processed in the following order for command plan: Group 1 - Module /github/workspace/dependencies-project/module1 - Module /github/workspace/dependencies-project/module2 Group 2 - Module /github/workspace/dependencies-project/app Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/local... Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/local... - Installing hashicorp/local v2.4.0... - Installing hashicorp/local v2.4.0... - Installed hashicorp/local v2.4.0 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! - Installed hashicorp/local v2.4.0 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # local_file.f1 will be created + resource "local_file" "f1" { + content = "file" + content_base64sha256 = (known after apply) + content_base64sha512 = (known after apply) + content_md5 = (known after apply) + content_sha1 = (known after apply) + content_sha256 = (known after apply) + content_sha512 = (known after apply) + directory_permission = "0777" + file_permission = "0777" + filename = "./file.txt" + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + file = "./file.txt" Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # local_file.f1 will be created + resource "local_file" "f1" { + content = "file" + content_base64sha256 = (known after apply) + content_base64sha512 = (known after apply) + content_md5 = (known after apply) + content_sha1 = (known after apply) + content_sha256 = (known after apply) + content_sha512 = (known after apply) + directory_permission = "0777" + file_permission = "0777" + filename = "./file.txt" + id = (known after apply) } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + file = "./file.txt" Initializing the backend... Initializing provider plugins... Terraform has been successfully initialized! No changes. Your infrastructure matches the configuration. Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed. ``` --- src/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.sh b/src/main.sh index fb337ed..d9b180c 100755 --- a/src/main.sh +++ b/src/main.sh @@ -153,7 +153,7 @@ function main { if [[ "${tg_comment}" == "1" ]]; then comment "Execution result of \`$tg_command\` in \`${tg_dir}\` : -\`\`\` +\`\`\`terraform ${terragrunt_output} \`\`\` "